nsprpub/configure.in

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 dnl -*- Mode: Autoconf; tab-width: 4; indent-tabs-mode: nil; -*-
     2 dnl 
     3 dnl This Source Code Form is subject to the terms of the Mozilla Public
     4 dnl License, v. 2.0. If a copy of the MPL was not distributed with this
     5 dnl file, You can obtain one at http://mozilla.org/MPL/2.0/.
     7 AC_PREREQ(2.61)
     8 AC_INIT
     9 AC_CONFIG_SRCDIR([pr/include/nspr.h])
    11 AC_CONFIG_AUX_DIR(${srcdir}/build/autoconf)
    12 AC_CANONICAL_TARGET
    14 dnl ========================================================
    15 dnl = Defaults
    16 dnl ========================================================
    17 MOD_MAJOR_VERSION=4
    18 MOD_MINOR_VERSION=10
    19 MOD_PATCH_VERSION=6
    20 NSPR_MODNAME=nspr20
    21 _HAVE_PTHREADS=
    22 USE_PTHREADS=
    23 USE_USER_PTHREADS=
    24 USE_NSPR_THREADS=
    25 USE_N32=
    26 USE_X32=
    27 USE_64=
    28 USE_CPLUS=
    29 USE_IPV6=
    30 USE_MDUPDATE=
    31 _MACOSX_DEPLOYMENT_TARGET=
    32 _OPTIMIZE_FLAGS=-O
    33 _DEBUG_FLAGS=-g
    34 MOZ_DEBUG=1
    35 MOZ_OPTIMIZE=
    36 OBJDIR='$(OBJDIR_NAME)'
    37 OBJDIR_NAME=.
    38 OBJDIR_SUFFIX=OBJ
    39 NSINSTALL='$(MOD_DEPTH)/config/$(OBJDIR_NAME)/nsinstall'
    40 NOSUCHFILE=/no-such-file
    41 LIBNSPR='-L$(dist_libdir) -lnspr$(MOD_MAJOR_VERSION)'
    42 LIBPLC='-L$(dist_libdir) -lplc$(MOD_MAJOR_VERSION)'
    43 CYGWIN_WRAPPER=
    44 MACOS_SDK_DIR=
    45 NEXT_ROOT=
    46 MT=
    47 MOZ_OS2_HIGH_MEMORY=1
    48 PROFILE_GEN_CFLAGS=
    49 PROFILE_GEN_LDFLAGS=
    50 PROFILE_USE_CFLAGS=
    51 PROFILE_USE_LDFLAGS=
    53 dnl Link in libraries necessary to resolve all symbols for shared libs
    54 RESOLVE_LINK_SYMBOLS=
    56 dnl ========================================================
    57 dnl =
    58 dnl = Dont change the following lines.  Doing so breaks:
    59 dnl =
    60 dnl = CFLAGS="-foo" ./configure
    61 dnl =
    62 dnl ========================================================
    63 CFLAGS="${CFLAGS=}"
    64 CXXFLAGS="${CXXFLAGS=}"
    65 LDFLAGS="${LDFLAGS=}"
    66 DLLFLAGS="${DLLFLAGS=}"
    67 HOST_CFLAGS="${HOST_CFLAGS=}"
    68 HOST_LDFLAGS="${HOST_LDFLAGS=}"
    70 case "$target" in
    71 *-cygwin*|*-mingw*|*-msys*)
    72     # Check to see if we are really running in a msvc environemnt
    73     _WIN32_MSVC=
    74     AC_CHECK_PROGS(CC, cl)
    75     if test "$CC" = "cl"; then
    76         echo 'main() { return 0; }' > dummy.c
    77         ${CC} -o dummy dummy.c >/dev/null 2>&1
    78         if test $? = 0; then
    79             _WIN32_MSVC=1
    80             CXX=$CC
    81         else
    82             AC_MSG_WARN([$(CC) test failed.  Using normal feature tests])
    83         fi
    84         rm -f dummy dummy.o dummy.obj dummy.exe dummy.c
    85     fi
    86     ;;
    87 *-mks*)
    88     _WIN32_MSVC=1
    89     ;;
    90 esac
    92 if test -n "$_WIN32_MSVC"; then
    93     SKIP_PATH_CHECKS=1
    94     SKIP_COMPILER_CHECKS=1
    95     SKIP_LIBRARY_CHECKS=1
    96 fi
    98 dnl ========================================================
    99 dnl = Android uses a very custom (hacky) toolchain; we need to do this
   100 dnl = here, so that the compiler checks can succeed
   101 dnl ========================================================
   103 AC_ARG_WITH(android-ndk,
   104 [  --with-android-ndk=DIR
   105                           location where the Android NDK can be found],
   106     android_ndk=$withval)
   108 AC_ARG_WITH(android-toolchain,
   109 [  --with-android-toolchain=DIR
   110                           location of the Android toolchain],
   111     android_toolchain=$withval)
   113 dnl The default android_version is different for each target cpu.
   114 case "$target_cpu" in
   115 arm)
   116     android_version=5
   117     ;;
   118 i?86|mipsel)
   119     android_version=9
   120     ;;
   121 esac
   123 AC_ARG_WITH(android-version,
   124 [  --with-android-version=VER
   125                           Android platform version, default 5 for arm, 9 for x86/mips],
   126     android_version=$withval)
   128 AC_ARG_WITH(android-platform,
   129 [  --with-android-platform=DIR
   130                           location of platform dir],
   131     android_platform=$withval)
   133 case "$target" in
   134 arm-linux*-android*|*-linuxandroid*)
   135     android_tool_prefix="arm-linux-androideabi"
   136     ;;
   137 i?86-*android*)
   138     android_tool_prefix="i686-linux-android"
   139     ;;
   140 mipsel-*android*)
   141     android_tool_prefix="mipsel-linux-android"
   142     ;;
   143 *)
   144     android_tool_prefix="$target_os"
   145     ;;
   146 esac
   148 dnl ========================================================
   149 dnl = Gonk is a fork of Android used for Mozilla's B2G project.
   150 dnl = Configuration is done largely by the top level config
   151 dnl = and the specified gonk directory doesn't matter here.
   152 dnl ========================================================
   154 AC_ARG_WITH(gonk,
   155 [  --with-gonk=DIR         location of gonk dir],
   156     gonkdir=$withval)
   158 if test -n "$gonkdir" ; then
   159     dnl Most things are directly configured by env vars when building for gonk
   161     dnl prevent cross compile section from using these flags as host flags
   162     if test -z "$HOST_CPPFLAGS" ; then
   163         HOST_CPPFLAGS=" "
   164     fi
   165     if test -z "$HOST_CFLAGS" ; then
   166         HOST_CFLAGS=" "
   167     fi
   168     if test -z "$HOST_CXXFLAGS" ; then
   169         HOST_CXXFLAGS=" "
   170     fi
   171     if test -z "$HOST_LDFLAGS" ; then
   172         HOST_LDFLAGS=" "
   173     fi
   175     AC_DEFINE(ANDROID)
   176 else
   177 case "$target" in
   178 *-android*|*-linuxandroid*)
   179     if test -z "$android_ndk" ; then
   180        AC_MSG_ERROR([You must specify --with-android-ndk=/path/to/ndk when targeting Android.])
   181     fi
   183     if test -z "$android_toolchain" ; then
   184         AC_MSG_CHECKING([for android toolchain directory])
   186         kernel_name=`uname -s | tr "[[:upper:]]" "[[:lower:]]"`
   188         case "$target_cpu" in
   189         arm)
   190             target_name=arm-linux-androideabi-4.4.3
   191             ;;
   192         i?86)
   193             target_name=x86-4.4.3
   194             ;;
   195         mipsel)
   196             target_name=mipsel-linux-android-4.4.3
   197             ;;
   198         esac
   199         android_toolchain="$android_ndk"/toolchains/$target_name/prebuilt/$kernel_name-x86
   201         if test -d "$android_toolchain" ; then
   202             AC_MSG_RESULT([$android_toolchain])
   203         else
   204             AC_MSG_ERROR([not found. You have to specify --with-android-toolchain=/path/to/ndk/toolchain.])
   205         fi
   206     fi
   208     if test -z "$android_platform" ; then
   209         AC_MSG_CHECKING([for android platform directory])
   211         case "$target_cpu" in
   212         arm)
   213             target_name=arm
   214             ;;
   215         i?86)
   216             target_name=x86
   217             ;;
   218         mipsel)
   219             target_name=mips
   220             ;;
   221         esac
   223         android_platform="$android_ndk"/platforms/android-"$android_version"/arch-"$target_name"
   225         if test -d "$android_platform" ; then
   226             AC_MSG_RESULT([$android_platform])
   227         else
   228             AC_MSG_ERROR([not found. You have to specify --with-android-platform=/path/to/ndk/platform.])
   229         fi
   230     fi
   232     dnl Old NDK support. If minimum requirement is changed to NDK r8b,
   233     dnl please remove this.
   234     case "$target_cpu" in
   235     i?86)
   236         if ! test -e "$android_toolchain"/bin/"$android_tool_prefix"-gcc; then
   237             dnl Old NDK toolchain name
   238             android_tool_prefix="i686-android-linux"
   239         fi
   240         ;;
   241     esac
   243     dnl set up compilers
   244     AS="$android_toolchain"/bin/"$android_tool_prefix"-as
   245     CC="$android_toolchain"/bin/"$android_tool_prefix"-gcc
   246     CXX="$android_toolchain"/bin/"$android_tool_prefix"-g++
   247     CPP="$android_toolchain"/bin/"$android_tool_prefix"-cpp
   248     LD="$android_toolchain"/bin/"$android_tool_prefix"-ld
   249     AR="$android_toolchain"/bin/"$android_tool_prefix"-ar
   250     RANLIB="$android_toolchain"/bin/"$android_tool_prefix"-ranlib
   251     STRIP="$android_toolchain"/bin/"$android_tool_prefix"-strip
   253     CPPFLAGS="-I$android_platform/usr/include $CPPFLAGS"
   254     CFLAGS="-mandroid -I$android_platform/usr/include -fno-short-enums -fno-exceptions $CFLAGS"
   255     CXXFLAGS="-mandroid -I$android_platform/usr/include -fpic -fno-short-enums -fno-exceptions $CXXFLAGS"
   256     LDFLAGS="-mandroid -L$android_platform/usr/lib -Wl,-rpath-link=$android_platform/usr/lib --sysroot=$android_platform $LDFLAGS"
   258     dnl prevent cross compile section from using these flags as host flags
   259     if test -z "$HOST_CPPFLAGS" ; then
   260         HOST_CPPFLAGS=" "
   261     fi
   262     if test -z "$HOST_CFLAGS" ; then
   263         HOST_CFLAGS=" "
   264     fi
   265     if test -z "$HOST_CXXFLAGS" ; then
   266         HOST_CXXFLAGS=" "
   267     fi
   268     if test -z "$HOST_LDFLAGS" ; then
   269         HOST_LDFLAGS=" "
   270     fi
   272     AC_DEFINE(ANDROID)
   273     ;;
   274 esac
   275 fi
   277 dnl ========================================================
   278 dnl =
   279 dnl = Check options that may affect the compiler
   280 dnl =
   281 dnl ========================================================
   282 dist_prefix='${MOD_DEPTH}/dist'
   283 dist_bindir='${dist_prefix}/bin'
   284 dist_includedir='${dist_prefix}/include/nspr'
   285 dist_libdir='${dist_prefix}/lib'
   286 dnl If the --includedir option was not specified, add '/nspr' to autoconf's
   287 dnl default value of includedir.
   288 if test "${includedir}" = '${prefix}/include'; then
   289     includedir='${prefix}/include/nspr'
   290 fi
   292 AC_ARG_WITH(dist-prefix,
   293     [  --with-dist-prefix=DIST_PREFIX
   294                           place build files in DIST_PREFIX [dist]],
   295     dist_prefix=$withval)
   297 AC_ARG_WITH(dist-bindir,
   298     [  --with-dist-bindir=DIR  build execuatables in DIR [DIST_PREFIX/bin]],
   299     dist_bindir=$withval)
   301 AC_ARG_WITH(dist-includedir,
   302     [  --with-dist-includedir=DIR
   303                           build include files in DIR [DIST_PREFIX/include/nspr]],
   304     dist_includedir=$withval)
   306 AC_ARG_WITH(dist-libdir,
   307     [  --with-dist-libdir=DIR  build library files in DIR [DIST_PREFIX/lib]],
   308     dist_libdir=$withval)
   310 AC_SUBST(dist_prefix)
   311 AC_SUBST(dist_bindir)
   312 AC_SUBST(dist_includedir)
   313 AC_SUBST(dist_libdir)
   315 dnl Check if NSPR is being compiled for Mozilla
   316 dnl Let --with-arg override environment setting
   317 dnl
   318 AC_ARG_WITH(mozilla,
   319     [  --with-mozilla          Compile NSPR with Mozilla support],
   320     [   if test "$withval" = "yes"; then
   321             AC_DEFINE(MOZILLA_CLIENT)
   322             MOZILLA_CLIENT=1
   323 	    else
   324 	        MOZILLA_CLIENT=
   325 	    fi],
   326     [	if test -n "$MOZILLA_CLIENT"; then
   327 	        AC_DEFINE(MOZILLA_CLIENT)
   328 	    fi])
   330 AC_ARG_ENABLE(optimize,
   331     [  --enable-optimize[=OPT] Enable code optimizations (ie. -O2) ],
   332     [ if test "$enableval" != "no"; then
   333           MOZ_OPTIMIZE=1
   334           if test -n "$enableval" -a "$enableval" != "yes"; then
   335             _OPTIMIZE_FLAGS=`echo $enableval | sed -e 's|\\\ | |g'`
   336             _SAVE_OPTIMIZE_FLAGS=$_OPTIMIZE_FLAGS
   337           fi
   338       else
   339           MOZ_OPTIMIZE=
   340       fi ])
   342 AC_ARG_ENABLE(debug,
   343     [  --enable-debug[=DBG]    Enable debugging (using compiler flags DBG)],
   344     [ if test "$enableval" != "no"; then
   345           MOZ_DEBUG=1
   346           MOZ_DEBUG_SYMBOLS=1
   347           if test -n "$enableval" -a "$enableval" != "yes"; then
   348               _DEBUG_FLAGS=`echo $enableval | sed -e 's|\\\ | |g'`
   349               _SAVE_DEBUG_FLAGS=$_DEBUG_FLAGS
   350           fi
   351       else
   352           MOZ_DEBUG=
   353       fi ],
   354       MOZ_DEBUG_SYMBOLS=1)
   356 AC_ARG_ENABLE(debug-symbols,
   357     [  --enable-debug-symbols[=DBG]    Enable debugging symbols
   358                                        (using compiler flags DBG)],
   359     [ if test "$enableval" != "no"; then
   360           MOZ_DEBUG_SYMBOLS=1
   361           if test -n "$enableval" -a "$enableval" != "yes"; then
   362               if test -z "$_SAVE_DEBUG_FLAGS"; then
   363                   _DEBUG_FLAGS=`echo $enableval | sed -e 's|\\\ | |g'`
   364                   _SAVE_DEBUG_FLAGS=$_DEBUG_FLAGS
   365               else
   366                   AC_MSG_ERROR([--enable-debug-symbols flags cannot be used with --enable-debug flags])
   367               fi
   368           fi
   369       else
   370           MOZ_DEBUG_SYMBOLS=
   371       fi ])
   373 AC_ARG_ENABLE(win32-target,
   374     [  --enable-win32-target=\$t
   375                           Specify win32 flavor. (WIN95 or WINNT)],
   376     OS_TARGET=`echo $enableval | tr a-z A-Z`)
   378 AC_ARG_ENABLE(symbian-target,
   379     [  --enable-symbian-target=\$t
   380                           Specify symbian flavor. (WINSCW or GCCE)],
   381     OS_TARGET=`echo $enableval | tr a-z A-Z`)
   383 AC_ARG_ENABLE(debug-rtl,
   384     [  --enable-debug-rtl      Use the MSVC debug runtime library],
   385     [ if test "$enableval" = "yes"; then
   386 	    USE_DEBUG_RTL=1
   387       else
   388 	    USE_DEBUG_RTL=0
   389       fi ])
   391 AC_ARG_ENABLE(n32,
   392     [  --enable-n32            Enable n32 ABI support (IRIX only)],
   393     [ if test "$enableval" = "yes"; then
   394 	USE_N32=1
   395       else if test "$enableval" = "no"; then
   396 	USE_N32=
   397       fi
   398     fi ])
   400 AC_ARG_ENABLE(x32,
   401     [  --enable-x32            Enable x32 ABI support (x86_64 only)],
   402     [ if test "$enableval" = "yes"; then
   403         USE_X32=1
   404       else if test "$enableval" = "no"; then
   405         USE_X32=
   406       fi
   407     fi ])
   409 AC_ARG_ENABLE(64bit,
   410     [  --enable-64bit          Enable 64-bit support (on certain platforms)],
   411     [ if test "$enableval" = "yes"; then
   412 	    USE_64=1
   413       fi ])
   415 AC_ARG_ENABLE(mdupdate,
   416     [  --enable-mdupdate       Enable use of certain compilers' mdupdate feature],
   417     [ if test "$enableval" = "yes"; then
   418 	    USE_MDUPDATE=1
   419       fi ])
   421 AC_ARG_ENABLE(cplus,
   422     [  --enable-cplus          Enable some c++ api routines],
   423     [ if test "$enableval" = "yes"; then
   424 	    USE_CPLUS=1
   425       fi]) 
   427 AC_ARG_WITH(arm-kuser,
   428     [  --with-arm-kuser        Use kuser helpers (Linux/ARM only)
   429                           (Requires kernel 2.6.13 or later)],
   430     [ if test "$withval" = "yes"; then
   431 	    AC_DEFINE(_PR_ARM_KUSER)
   432       fi ])
   434 dnl ========================================================
   435 dnl = Mac OS X SDK support
   436 dnl ========================================================
   437 AC_ARG_WITH(macos-sdk,
   438     [  --with-macos-sdk=dir    Location of platform SDK to use (Mac OS X only)],
   439     MACOS_SDK_DIR=$withval)
   441 AC_ARG_ENABLE(macos-target,
   442              [  --enable-macos-target=VER
   443                           Set the minimum MacOS version needed at runtime
   444                           [10.2 for ppc, 10.4 for x86]],
   445              [_MACOSX_DEPLOYMENT_TARGET=$enableval])
   447 dnl ========================================================
   448 dnl =
   449 dnl = Set the threading model
   450 dnl =
   451 dnl ========================================================
   452 case "$target" in
   454 *-aix*)
   455     case "${target_os}" in
   456     aix3.2*)
   457         USE_NSPR_THREADS=1
   458         ;;
   459     *)
   460         USE_PTHREADS=1
   461         ;;
   462     esac
   463     ;;
   465 esac
   467 dnl ========================================================
   468 dnl =
   469 dnl = Set the default C compiler
   470 dnl =
   471 dnl ========================================================
   472 if test -z "$CC"; then
   473     case "$target" in
   475     *-aix*)
   476         if test -z "$USE_NSPR_THREADS"; then
   477             CC=xlc_r
   478         else
   479             CC=xlc
   480         fi
   481     ;;
   483     *-hpux*)
   484         CC=cc
   485     ;;
   487     *-irix*)
   488         CC=cc
   489     ;;
   491     *-osf*)
   492         CC=cc
   493     ;;
   495     *-solaris*)
   496         CC=cc
   497     ;;
   499     esac
   500 fi
   502 dnl ========================================================
   503 dnl =
   504 dnl = Set the default C++ compiler
   505 dnl =
   506 dnl ========================================================
   507 if test -z "$CXX"; then
   508     case "$target" in
   510     *-aix*)
   511         if test -z "$USE_NSPR_THREADS"; then
   512             CXX=xlC_r
   513         else
   514             CXX=xlC
   515         fi
   516     ;;
   518     *-hpux*)
   519         case "${target_os}" in
   520         hpux10.30)
   521             CXX=aCC
   522             ;;
   523         hpux11.*)
   524             CXX=aCC
   525             ;;
   526         *)
   527             CXX=CC
   528             ;;
   529         esac
   530     ;;
   532     *-irix*)
   533         CXX=CC
   534     ;;
   536     *-osf*)
   537         CXX=cxx
   538     ;;
   540     *-solaris*)
   541         CXX=CC
   542     ;;
   544     esac
   545 fi
   547 if test -z "$SKIP_PATH_CHECKS"; then
   548     AC_PATH_PROG(WHOAMI, $WHOAMI whoami, echo not_whoami)
   549 fi
   551 if test -n "$MOZ_DEBUG"; then
   552     AC_DEFINE(DEBUG)
   553     DEFINES="$DEFINES -UNDEBUG"
   555     case "${target_os}" in
   556     beos*)
   557         DEFINES="$DEFINES -DDEBUG_${USER}"
   558         ;;
   559     mks*|cygwin*|mingw*|msys*|os2*)
   560         DEFINES="$DEFINES -DDEBUG_`echo ${USERNAME} | sed -e 's| |_|g'`"
   561         ;;
   562     *)
   563         DEFINES="$DEFINES -DDEBUG_`$WHOAMI`"
   564         ;;
   565     esac
   566 else
   567     AC_DEFINE(NDEBUG)
   568     DEFINES="$DEFINES -UDEBUG"
   569 fi
   571 if test -z "$SKIP_COMPILER_CHECKS"; then
   572 dnl ========================================================
   573 dnl Checks for compilers.
   574 dnl ========================================================
   575 if test "$target" != "$host"; then
   576     echo "cross compiling from $host to $target"
   577     cross_compiling=yes
   579     case "$build:$target" in
   580       powerpc-apple-darwin8*:i?86-apple-darwin*)
   581         dnl The Darwin cross compiler doesn't necessarily point itself at a
   582         dnl root that has libraries for the proper architecture, it defaults
   583         dnl to the system root.  The libraries in the system root on current
   584         dnl versions of PPC OS X 10.4 aren't fat, so these target compiler
   585         dnl checks will fail.  Fake a working SDK in that case.
   586         _SAVE_CFLAGS=$CFLAGS
   587         _SAVE_CXXFLAGS=$CXXFLAGS
   588         CFLAGS="-isysroot /Developer/SDKs/MacOSX10.4u.sdk $CFLAGS"
   589         CXXFLAGS="-isysroot /Developer/SDKs/MacOSX10.4u.sdk $CXXFLAGS"
   590         ;;
   591       *:arm*-apple-darwin*)
   592         dnl The arm compiler doesn't appear to know about its root by default,
   593         dnl so explicitly pass it one here. Later on we'll put this in CFLAGS
   594         dnl anyway.
   595         _SAVE_CFLAGS=$CFLAGS
   596         _SAVE_CXXFLAGS=$CXXFLAGS
   597         CFLAGS="-isysroot $MACOS_SDK_DIR $CFLAGS"
   598         CXXFLAGS="-isysroot $MACOS_SDK_DIR $CXXFLAGS"
   599         ;;
   600     esac
   602     AC_CHECK_PROGS(CC, $CC "${target_alias}-gcc" "${target}-gcc", echo)
   603     unset ac_cv_prog_CC
   604     dnl Now exit the conditional block to invoke AC_PROG_CC.
   605 fi
   607 dnl In the latest versions of autoconf, AC_PROG_CC is a one-shot macro,
   608 dnl declared with AC_DEFUN_ONCE. So it must not be expanded inside a
   609 dnl conditional block. Invoke AC_PROG_CC outside any conditional block
   610 dnl and before invoking AC_TRY_COMPILE (which requires AC_PROG_CC).
   611 AC_PROG_CC
   613 dnl Reenter the conditional blocks after invoking AC_PROG_CC.
   614 if test "$target" != "$host"; then
   615     if test -n "$USE_CPLUS"; then
   616         AC_CHECK_PROGS(CXX, $CXX "${target_alias}-g++" "${target}-g++", echo)
   617         unset ac_cv_prog_CXX
   618         AC_PROG_CXX
   619     fi
   621     case "$build:$target" in
   622       powerpc-apple-darwin8*:i?86-apple-darwin*|*:arm*-apple-darwin*)
   623         dnl Revert the changes made above.  From this point on, the target
   624         dnl compiler will never be used without applying the SDK to CFLAGS
   625         dnl (see --with-macos-sdk below).
   626         CFLAGS=$_SAVE_CFLAGS
   627         CXXFLAGS=$_SAVE_CXXFLAGS
   628         ;;
   629     esac
   631     AC_CHECK_PROGS(RANLIB, $RANLIB "${target_alias}-ranlib" "${target}-ranlib", echo)
   632     AC_CHECK_PROGS(AR, $AR "${target_alias}-ar" "${target}-ar", echo)
   633     AC_CHECK_PROGS(AS, $AS "${target_alias}-as" "${target}-as", echo)
   634     AC_CHECK_PROGS(LD, $LD "${target_alias}-ld" "${target}-ld", echo)
   635     AC_CHECK_PROGS(STRIP, $STRIP "${target_alias}-strip" "${target}-strip", echo)
   636     AC_CHECK_PROGS(WINDRES, $WINDRES "${target_alias}-windres" "${target}-windres", echo)
   638     _SAVE_CC="$CC"
   639     _SAVE_CFLAGS="$CFLAGS"
   640     _SAVE_LDFLAGS="$LDFLAGS"
   642     AC_MSG_CHECKING([for $host compiler])
   643     AC_CHECK_PROGS(HOST_CC, $HOST_CC gcc cc /usr/ucb/cc, "")
   644     if test -z "$HOST_CC"; then
   645         AC_MSG_ERROR([no acceptable cc found in \$PATH])
   646     fi
   647     AC_MSG_RESULT([$HOST_CC])
   648     if test -z "$HOST_CFLAGS"; then
   649         HOST_CFLAGS="$CFLAGS"
   650     fi
   651     if test -z "$HOST_LDFLAGS"; then
   652         HOST_LDFLAGS="$LDFLAGS"
   653     fi
   655     CC="$HOST_CC"
   656     CFLAGS="$HOST_CFLAGS"
   657     LDFLAGS="$HOST_LDFLAGS"
   659     AC_MSG_CHECKING([whether the $host compiler ($HOST_CC $HOST_CFLAGS $HOST_LDFLAGS) works])
   660     AC_TRY_COMPILE([], [return 0;],
   661         [AC_MSG_RESULT([yes])],
   662         [AC_MSG_ERROR([installation or configuration problem: $host compiler $HOST_CC cannot create executables.])] )
   664     CC=$_SAVE_CC
   665     CFLAGS=$_SAVE_CFLAGS
   666     LDFLAGS=$_SAVE_LDFLAGS
   667 else
   668     if test -n "$USE_CPLUS"; then
   669         if test "$CC" = "cl" -a -z "$CXX"; then
   670             CXX=$CC
   671         else
   672             AC_PROG_CXX
   673         fi
   674     fi
   675     AC_PROG_RANLIB
   676     AC_PATH_PROGS(AS, as, $CC)
   677     AC_PATH_PROGS(AR, ar, echo not_ar)
   678     AC_PATH_PROGS(LD, ld link, echo not_ld)
   679     AC_PATH_PROGS(STRIP, strip, echo not_strip)
   680     AC_PATH_PROGS(WINDRES, windres, echo not_windres)
   681     if test -z "$HOST_CC"; then
   682         HOST_CC="$CC"
   683     fi
   684     if test -z "$HOST_CFLAGS"; then
   685         HOST_CFLAGS="$CFLAGS"
   686     fi
   687 fi
   689 AC_PROG_CPP
   691 if test "$GCC" = "yes"; then
   692     GNU_CC=1
   693 fi
   694 if test "$GXX" = "yes"; then
   695     GNU_CXX=1
   696 fi
   697 if test "`echo | $AS -v 2>&1 | grep -c GNU`" != "0"; then
   698     GNU_AS=1
   699 fi
   700 rm -f a.out
   702 case "$build:$target" in
   703     i?86-apple-darwin*:powerpc-apple-darwin*)
   704         dnl cross_compiling will have erroneously been set to "no" in this
   705         dnl case, because the x86 build host is able to run ppc code in a
   706         dnl translated environment, making a cross compiler appear native.
   707         cross_compiling=yes
   708         ;;
   709 esac
   711 if test "$cross_compiling"  = "yes"; then
   712     CROSS_COMPILE=1
   713 else
   714     CROSS_COMPILE=
   715 fi
   717 dnl ========================================================
   718 dnl Check for gcc -pipe support
   719 dnl ========================================================
   720 AC_MSG_CHECKING([for gcc -pipe support])
   721 if test -n "$GNU_CC" && test -n "$GNU_CXX" && test -n "$GNU_AS"; then
   722     echo '#include <stdio.h>' > dummy-hello.c
   723     echo 'int main() { printf("Hello World\n"); return 0; }' >> dummy-hello.c
   724     ${CC} -S dummy-hello.c -o dummy-hello.s 2>&5
   725     cat dummy-hello.s | ${AS} -o dummy-hello.S - 2>&5
   726     if test $? = 0; then
   727         _res_as_stdin="yes"
   728     else
   729         _res_as_stdin="no"
   730     fi
   731     if test "$_res_as_stdin" = "yes"; then
   732         _SAVE_CFLAGS=$CFLAGS
   733         CFLAGS="$CFLAGS -pipe"
   734         AC_TRY_COMPILE( [ #include <stdio.h> ],
   735             [printf("Hello World\n");],
   736             [_res_gcc_pipe="yes"],
   737             [_res_gcc_pipe="no"] )
   738         CFLAGS=$_SAVE_CFLAGS
   739     fi
   740     if test "$_res_as_stdin" = "yes" && test "$_res_gcc_pipe" = "yes"; then
   741         _res="yes";
   742         CFLAGS="$CFLAGS -pipe"
   743         CXXFLAGS="$CXXFLAGS -pipe"
   744     else
   745         _res="no"
   746     fi
   747     rm -f dummy-hello.c dummy-hello.s dummy-hello.S dummy-hello a.out
   748     AC_MSG_RESULT([$_res])
   749 else
   750     AC_MSG_RESULT([no])
   751 fi
   753 dnl ========================================================
   754 dnl Profile guided optimization
   755 dnl ========================================================
   756 dnl Test for profiling options
   757 dnl Under gcc 3.4+, use -fprofile-generate/-fprofile-use
   759 _SAVE_CFLAGS="$CFLAGS"
   760 CFLAGS="$CFLAGS -fprofile-generate -fprofile-correction"
   762 AC_MSG_CHECKING([whether C compiler supports -fprofile-generate])
   763 AC_TRY_COMPILE([], [return 0;],
   764                [ PROFILE_GEN_CFLAGS="-fprofile-generate"
   765                  result="yes" ], result="no")
   766 AC_MSG_RESULT([$result])
   768 if test $result = "yes"; then
   769    PROFILE_GEN_LDFLAGS="-fprofile-generate"
   770    PROFILE_USE_CFLAGS="-fprofile-use -fprofile-correction -Wcoverage-mismatch"
   771    PROFILE_USE_LDFLAGS="-fprofile-use"
   772 fi
   774 CFLAGS="$_SAVE_CFLAGS"
   776 dnl ===============================================================
   777 dnl Check for .hidden assembler directive and visibility attribute.
   778 dnl Borrowed from glibc configure.in
   779 dnl ===============================================================
   780 if test "$GNU_CC"; then
   781     AC_CACHE_CHECK(for visibility(hidden) attribute,
   782         ac_cv_visibility_hidden,
   783         [cat > conftest.c <<EOF
   784         int foo __attribute__ ((visibility ("hidden"))) = 1;
   785 EOF
   786         ac_cv_visibility_hidden=no
   787         if ${CC-cc} -Werror -S conftest.c -o conftest.s >/dev/null 2>&1; then
   788             if grep '\.hidden.*foo' conftest.s >/dev/null; then
   789                 ac_cv_visibility_hidden=yes
   790             fi
   791         fi
   792         rm -f conftest.[cs]
   793         ])
   794     if test "$ac_cv_visibility_hidden" = "yes"; then
   795         AC_DEFINE(HAVE_VISIBILITY_HIDDEN_ATTRIBUTE)
   796         AC_CACHE_CHECK(for visibility pragma support,
   797             ac_cv_visibility_pragma,
   798             [cat > conftest.c <<EOF
   799 #pragma GCC visibility push(hidden)
   800             int foo_hidden = 1;
   801 #pragma GCC visibility push(default)
   802             int foo_default = 1;
   803 EOF
   804             ac_cv_visibility_pragma=no
   805             if ${CC-cc} -Werror -S conftest.c -o conftest.s >/dev/null 2>&1; then
   806                 if grep '\.hidden.*foo_hidden' conftest.s >/dev/null; then
   807                     if ! grep '\.hidden.*foo_default' conftest.s > /dev/null; then
   808                         ac_cv_visibility_pragma=yes
   809                     fi
   810                 fi
   811             fi
   812             rm -f conftest.[cs]
   813             ])
   814         if test "$ac_cv_visibility_pragma" = "yes"; then
   815             AC_DEFINE(HAVE_VISIBILITY_PRAGMA)
   816             # To work around a build problem on Linux x86-64 (Bugzilla bug
   817             # 293438), we use the -fvisibility=hidden flag.  This flag is less
   818             # optimal than #pragma GCC visibility push(hidden) because the flag
   819             # assumes that symbols defined outside the current source file have
   820             # the default visibility.  This has the advantage that we don't need
   821             # to wrap system header files, but has the disadvantage that calls
   822             # to hidden symbols defined in other source files cannot be
   823             # optimized by the compiler.  The -fvisibility=hidden flag does
   824             # hide and export symbols correctly.
   825             #VISIBILITY_FLAGS='-I$(dist_includedir)/system_wrappers -include $(topsrcdir)/config/gcc_hidden.h'
   826             #WRAP_SYSTEM_INCLUDES=1
   827             VISIBILITY_FLAGS="-fvisibility=hidden"
   828             WRAP_SYSTEM_INCLUDES=
   829         fi
   830     fi
   831 fi # GNU_CC
   833 fi # SKIP_COMPILER_CHECKS
   835 dnl ========================================================
   836 dnl Checks for programs.
   837 dnl ========================================================
   838 if test -z "$SKIP_PATH_CHECKS"; then
   839     AC_PATH_PROGS(PERL, perl5 perl, echo not_perl)
   840 elif test -z "$PERL"; then
   841     PERL=perl
   842 fi
   844 dnl ========================================================
   845 dnl Default platform specific options
   846 dnl ========================================================
   847 OBJ_SUFFIX=o
   848 LIB_SUFFIX=a
   849 DLL_SUFFIX=so
   850 ASM_SUFFIX=s
   851 MKSHLIB='$(LD) $(DSO_LDOPTS) -o $@'
   852 PR_MD_ASFILES=
   853 PR_MD_CSRCS=
   854 PR_MD_ARCH_DIR=unix
   855 AR_FLAGS='cr $@'
   856 AS='$(CC)'
   857 ASFLAGS='$(CFLAGS)'
   859 if test -n "$CROSS_COMPILE"; then
   860     OS_ARCH=`echo $target_os | sed -e 's|/|_|g'`
   861     OS_RELEASE=
   862     OS_TEST="${target_cpu}"
   863     case "${target_os}" in
   864         linux*)       OS_ARCH=Linux ;;
   865         solaris*)     OS_ARCH=SunOS OS_RELEASE=5 ;;
   866         mingw*)       OS_ARCH=WINNT CPU_ARCH=x86 ;;
   867         darwin*)      OS_ARCH=Darwin ;;
   868         riscos*)      OS_ARCH=RISCOS ;;
   869     esac
   870 else
   871     OS_ARCH=`uname -s | sed -e 's|/|_|g'`
   872     OS_RELEASE=`uname -r`
   873     OS_TEST=`uname -m`
   874 fi
   876 if test "$OS_ARCH" = "IRIX64"; then
   877     OS_ARCH=IRIX
   878 fi
   880 if test "$OS_ARCH" = "AIX"; then
   881     OS_RELEASE=`uname -v`.`uname -r`
   882 fi
   884 if test "$OS_ARCH" = "FreeBSD"; then
   885     OS_RELEASE=`echo $OS_RELEASE | sed 's/-.*//'`
   886 fi
   888 if test "$OS_ARCH" = "Linux"; then
   889     OS_RELEASE=`echo $OS_RELEASE | sed 's/-.*//'`
   890     OS_RELEASE=`echo $OS_RELEASE | awk -F\. '{ print $1 "." $2 }'`
   891 fi
   893 #######################################################################
   894 # Master "Core Components" macros for getting the OS target           #
   895 #######################################################################
   897 #
   898 # Note: OS_TARGET should be specified on the command line for gmake.
   899 # When OS_TARGET=WIN95 is specified, then a Windows 95 target is built.
   900 # The difference between the Win95 target and the WinNT target is that
   901 # the WinNT target uses Windows NT specific features not available
   902 # in Windows 95. The Win95 target will run on Windows NT, but (supposedly)
   903 # at lesser performance (the Win95 target uses threads; the WinNT target
   904 # uses fibers).
   905 #
   906 # If OS_TARGET is not specified, it defaults to $(OS_ARCH), i.e., no
   907 # cross-compilation.
   908 #
   910 #
   911 # The following hack allows one to build on a WIN95 machine (as if
   912 # s/he were cross-compiling on a WINNT host for a WIN95 target).
   913 # It also accomodates for MKS's uname.exe.  If you never intend
   914 # to do development on a WIN95 machine, you don't need this hack.
   915 #
   916 case "$OS_ARCH" in
   917 Windows_95)
   918     OS_ARCH=Windows_NT
   919     OS_TARGET=WIN95
   920     ;;
   921 Windows_98)
   922     OS_ARCH=Windows_NT
   923     OS_TARGET=WIN95
   924     ;;
   925 CYGWIN_9*|CYGWIN_ME*)
   926     OS_ARCH='CYGWIN_NT-4.0'
   927     OS_TARGET=WIN95
   928     ;;
   929 OS_2)
   930     OS_ARCH=OS2
   931     OS_TARGET=OS2
   932     ;;
   933 esac
   935 #
   936 # On WIN32, we also define the variable CPU_ARCH.
   937 #
   939 case "$OS_ARCH" in
   940 Windows_NT)
   941 #
   942 # If uname -s returns "Windows_NT", we assume that we are using
   943 # the uname.exe in MKS toolkit.
   944 #
   945 # The -r option of MKS uname only returns the major version number.
   946 # So we need to use its -v option to get the minor version number.
   947 # Moreover, it doesn't have the -p option, so we need to use uname -m.
   948 #
   949     OS_ARCH=WINNT
   950     OS_MINOR_RELEASE=`uname -v`
   951     if test "$OS_MINOR_RELEASE" = "00"; then
   952         OS_MINOR_RELEASE=0
   953     fi
   954     OS_RELEASE="${OS_RELEASE}.${OS_MINOR_RELEASE}"
   955     CPU_ARCH=`uname -m`
   956     #
   957     # MKS's uname -m returns "586" on a Pentium machine.
   958     #
   959     if echo "$CPU_ARCH" | grep -c 86 >/dev/null; then
   960         CPU_ARCH=x86
   961     fi
   962     ;;
   963 CYGWIN_NT*|MINGW*_NT*|MSYS_NT*)
   964 #
   965 # If uname -s returns "CYGWIN_NT-4.0", we assume that we are using
   966 # the uname.exe in the Cygwin tools.
   967 # If uname -s returns "MINGW32_NT-5.1", we assume that we are using
   968 # the uname.exe in the MSYS tools.
   969 # If uname -s returns "MSYS_NT-6.3", we assume that we are using
   970 # the uname.exe in the MSYS2 tools.
   971 #
   972     OS_RELEASE=`expr $OS_ARCH : '.*NT-\(.*\)'`
   973     OS_ARCH=WINNT
   974     CPU_ARCH=`uname -m`
   975     #
   976     # Cygwin's uname -m returns "i686" on a Pentium Pro machine.
   977     #
   978     if echo "$CPU_ARCH" | grep -c 86 >/dev/null; then
   979         CPU_ARCH=x86
   980     fi
   981     ;;
   982 esac
   984 if test -n "$MOZILLA_CLIENT" && test "$OS_ARCH" = "WINNT"; then
   985     OS_TARGET=WIN95
   986     if test -n "$MOZ_DEBUG" -a -z "$USE_DEBUG_RTL"; then
   987         USE_DEBUG_RTL=1
   988     fi
   989 fi
   990 if test -z "$OS_TARGET"; then
   991     OS_TARGET=$OS_ARCH
   992 fi
   993 if test "$OS_TARGET" = "WIN95"; then
   994     OS_RELEASE="4.0"
   995 fi
   996 OS_CONFIG="${OS_TARGET}${OS_RELEASE}"
   998 dnl ========================================================
   999 dnl Enable high-memory support on OS/2 by default.
  1000 dnl ========================================================
  1001 AC_ARG_ENABLE(os2-high-mem,
  1002     [  --disable-os2-high-mem  Disable high-memory support on OS/2],
  1003     [ if test "$enableval" = "no"; then
  1004         MOZ_OS2_HIGH_MEMORY=
  1005       else
  1006         MOZ_OS2_HIGH_MEMORY=1
  1007       fi ])
  1009 dnl ========================================================
  1010 dnl = ARM toolchain tweaks
  1011 dnl ========================================================
  1013 dnl Defaults
  1014 MOZ_ALIGN=toolchain-default
  1016 case "$target" in
  1017 arm*-android*|arm*-linuxandroid*)
  1018     MOZ_THUMB=yes
  1019     MOZ_ARCH=armv7-a
  1020     MOZ_FPU=vfp
  1021     MOZ_FLOAT_ABI=softfp
  1022     MOZ_SOFT_FLOAT=yes
  1023     MOZ_ALIGN=no
  1024     ;;
  1025 arm*-*)
  1026     if test -n "$MOZ_PLATFORM_MAEMO"; then
  1027         MOZ_THUMB=no
  1028         MOZ_ARCH=armv7-a
  1029         MOZ_FLOAT_ABI=softfp
  1030     fi
  1031     if test "$MOZ_PLATFORM_MAEMO" = 6; then
  1032         MOZ_THUMB=yes
  1033     fi
  1034     ;;
  1035 esac
  1037 dnl Kept for compatibility with some buildbot mozconfig
  1038 AC_ARG_ENABLE(thumb2, [], MOZ_THUMB=$enableval)
  1040 AC_ARG_WITH(thumb,
  1041 [  --with-thumb[[=yes|no|toolchain-default]]]
  1042 [                          Use Thumb instruction set (-mthumb)],
  1043     if test -z "$GNU_CC"; then
  1044         AC_MSG_ERROR([--with-thumb is not supported on non-GNU toolchain-defaults])
  1045     fi
  1046     MOZ_THUMB=$withval)
  1048 AC_ARG_WITH(thumb-interwork,
  1049 [  --with-thumb-interwork[[=yes|no|toolchain-default]]
  1050                            Use Thumb/ARM instuctions interwork (-mthumb-interwork)],
  1051     if test -z "$GNU_CC"; then
  1052         AC_MSG_ERROR([--with-thumb-interwork is not supported on non-GNU toolchain-defaults])
  1053     fi
  1054     MOZ_THUMB_INTERWORK=$withval)
  1056 AC_ARG_WITH(arch,
  1057 [  --with-arch=[[type|toolchain-default]]
  1058                            Use specific CPU features (-march=type)],
  1059     if test -z "$GNU_CC"; then
  1060         AC_MSG_ERROR([--with-arch is not supported on non-GNU toolchain-defaults])
  1061     fi
  1062     MOZ_ARCH=$withval)
  1064 AC_ARG_WITH(fpu,
  1065 [  --with-fpu=[[type|toolchain-default]]
  1066                            Use specific FPU type (-mfpu=type)],
  1067     if test -z "$GNU_CC"; then
  1068         AC_MSG_ERROR([--with-fpu is not supported on non-GNU toolchain-defaults])
  1069     fi
  1070     MOZ_FPU=$withval)
  1072 AC_ARG_WITH(float-abi,
  1073 [  --with-float-abi=[[type|toolchain-default]]
  1074                            Use specific arm float ABI (-mfloat-abi=type)],
  1075     if test -z "$GNU_CC"; then
  1076         AC_MSG_ERROR([--with-float-abi is not supported on non-GNU toolchain-defaults])
  1077     fi
  1078     MOZ_FLOAT_ABI=$withval)
  1080 AC_ARG_WITH(soft-float,
  1081 [  --with-soft-float[[=yes|no|toolchain-default]]
  1082                            Use soft float library (-msoft-float)],
  1083     if test -z "$GNU_CC"; then
  1084         AC_MSG_ERROR([--with-soft-float is not supported on non-GNU toolchain-defaults])
  1085     fi
  1086     MOZ_SOFT_FLOAT=$withval)
  1088 case "$MOZ_ARCH" in
  1089 toolchain-default|"")
  1090     arch_flag=""
  1091     ;;
  1092 *)
  1093     arch_flag="-march=$MOZ_ARCH"
  1094     ;;
  1095 esac
  1097 case "$MOZ_THUMB" in
  1098 yes)
  1099     MOZ_THUMB2=1
  1100     thumb_flag="-mthumb"
  1101     ;;
  1102 no)
  1103     MOZ_THUMB2=
  1104     thumb_flag="-marm"
  1105     ;;
  1106 *)
  1107     _SAVE_CFLAGS="$CFLAGS"
  1108     CFLAGS="$arch_flag"
  1109     AC_TRY_COMPILE([],[return sizeof(__thumb2__);],
  1110         MOZ_THUMB2=1,
  1111         MOZ_THUMB2=)
  1112     CFLAGS="$_SAVE_CFLAGS"
  1113     thumb_flag=""
  1114     ;;
  1115 esac
  1117 case "$MOZ_THUMB_INTERWORK" in
  1118 yes)
  1119     thumb_interwork_flag="-mthumb-interwork"
  1120     ;;
  1121 no)
  1122     thumb_interwork_flag="-mno-thumb-interwork"
  1123     ;;
  1124 *) # toolchain-default
  1125     thumb_interwork_flag=""
  1126     ;;
  1127 esac
  1129 case "$MOZ_FPU" in
  1130 toolchain-default|"")
  1131     fpu_flag=""
  1132     ;;
  1133 *)
  1134     fpu_flag="-mfpu=$MOZ_FPU"
  1135     ;;
  1136 esac
  1138 case "$MOZ_FLOAT_ABI" in
  1139 toolchain-default|"")
  1140     float_abi_flag=""
  1141     ;;
  1142 *)
  1143     float_abi_flag="-mfloat-abi=$MOZ_FLOAT_ABI"
  1144     ;;
  1145 esac
  1147 case "$MOZ_SOFT_FLOAT" in
  1148 yes)
  1149     soft_float_flag="-msoft-float"
  1150     ;;
  1151 no)
  1152     soft_float_flag="-mno-soft-float"
  1153     ;;
  1154 *) # toolchain-default
  1155     soft_float_flag=""
  1156     ;;
  1157 esac
  1159 case "$MOZ_ALIGN" in
  1160 toolchain-default|"")
  1161     align_flag=""
  1162     ;;
  1163 no)
  1164     align_flag="-mno-unaligned-access"
  1165     ;;
  1166 yes)
  1167     align_flag="-munaligned-access"
  1168     ;;
  1169 *)
  1170     align_flag=""
  1171     ;;
  1172 esac
  1174 if test -n "$align_flag"; then
  1175   _SAVE_CFLAGS="$CFLAGS"
  1176   CFLAGS="$CFLAGS $align_flag"
  1177   AC_MSG_CHECKING(whether alignment flag ($align_flag) is supported)
  1178   AC_TRY_COMPILE([],[],,align_flag="")
  1179   CFLAGS="$_SAVE_CFLAGS"
  1180 fi
  1182 dnl Use echo to avoid accumulating space characters
  1183 all_flags=`echo $arch_flag $thumb_flag $thumb_interwork_flag $fpu_flag $float_abi_flag $soft_float_flag $align_flag`
  1184 if test -n "$all_flags"; then
  1185     _SAVE_CFLAGS="$CFLAGS"
  1186     CFLAGS="$all_flags"
  1187     AC_MSG_CHECKING(whether the chosen combination of compiler flags ($all_flags) works)
  1188     AC_TRY_COMPILE([],[return 0;],
  1189         AC_MSG_RESULT([yes]),
  1190         AC_MSG_ERROR([no]))
  1192     CFLAGS="$_SAVE_CFLAGS $all_flags"
  1193     CXXFLAGS="$CXXFLAGS $all_flags"
  1194     ASFLAGS="$ASFLAGS $all_flags"
  1195     if test -n "$thumb_flag"; then
  1196         LDFLAGS="$LDFLAGS $thumb_flag"
  1197     fi
  1198 fi
  1200 dnl ========================================================
  1201 dnl Override of system specific host options
  1202 dnl ========================================================
  1203 case "$host" in
  1204 *-mingw*|*-msys*)
  1205     NSINSTALL=nsinstall
  1206     ;;
  1207 *-cygwin*|*-mks*)
  1208     NSINSTALL='$(CYGWIN_WRAPPER) nsinstall'
  1209     if test `echo "${PATH}" | grep -c \;` = 0; then
  1210         CYGWIN_WRAPPER='sh $(topsrcdir)/build/cygwin-wrapper'
  1211     fi
  1212     ;;
  1213 *-beos*)
  1214     HOST_CFLAGS="$HOST_CFLAGS -DXP_BEOS -DBeOS -DBEOS -D_POSIX_SOURCE"
  1215     ;;
  1216 *os2*)
  1217     ;;
  1218 *)
  1219     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
  1220     ;;
  1221 esac
  1223 dnl ========================================================
  1224 dnl Override of system specific target options
  1225 dnl ========================================================
  1226 case "$target" in
  1228 *-aix*)
  1229     AC_DEFINE(XP_UNIX)
  1230     AC_DEFINE(AIX)
  1231     AC_DEFINE(SYSV)
  1232     DSO_LDOPTS='-brtl -bnortllib -bM:SRE -bnoentry -bexpall -blibpath:/usr/lib:/lib'
  1233     AC_CHECK_HEADER(sys/atomic_op.h, AC_DEFINE(AIX_HAVE_ATOMIC_OP_H))
  1234     case "${target_os}" in
  1235     aix3.2*)
  1236         AC_DEFINE(AIX_RENAME_SELECT)
  1237         AC_DEFINE(_PR_NO_LARGE_FILES)
  1238         AIX_LINK_OPTS='-bnso -berok'
  1239         PR_MD_ASFILES=os_AIX.s
  1240         ;;
  1241     aix4.1*)
  1242         AC_DEFINE(AIX_TIMERS)
  1243         AC_DEFINE(_PR_NO_LARGE_FILES)
  1244         AC_DEFINE(AIX4_1)
  1245         MKSHLIB=
  1246         DSO_LDOPTS=
  1247         AIX_LINK_OPTS='-bnso -berok'
  1248         LIBNSPR='-L$(dist_libdir) -lnspr$(MOD_MAJOR_VERSION)_shr'
  1249         LIBPLC='-L$(dist_libdir) -lplc$(MOD_MAJOR_VERSION)_shr'
  1250         ;;
  1251     aix4.2*)
  1252         AC_DEFINE(AIX_TIMERS)
  1253         AC_DEFINE(_PR_HAVE_OFF64_T)
  1254         AIX_LINK_OPTS='-brtl -bnso -berok'
  1255         ;;
  1256     aix4.3*)
  1257         AC_DEFINE(AIX_TIMERS)
  1258         AC_DEFINE(_PR_HAVE_OFF64_T)
  1259         AC_DEFINE(AIX4_3_PLUS)
  1260         AC_DEFINE(HAVE_SOCKLEN_T)
  1261         AC_DEFINE(HAVE_FCNTL_FILE_LOCKING)
  1262         USE_IPV6=1
  1263         AIX_LINK_OPTS='-brtl -bnso -berok'
  1264         ;;
  1265     *)
  1266         AC_DEFINE(AIX_TIMERS)
  1267         AC_DEFINE(_PR_HAVE_OFF64_T)
  1268         AC_DEFINE(AIX4_3_PLUS)
  1269         AC_DEFINE(HAVE_SOCKLEN_T)
  1270         AC_DEFINE(HAVE_FCNTL_FILE_LOCKING)
  1271         USE_IPV6=1
  1272         AIX_LINK_OPTS='-brtl -bnso -berok'
  1273         ;;
  1274     esac
  1275     CFLAGS="$CFLAGS -qro -qroconst"
  1276     AIX_WRAP='$(DIST)/lib/aixwrap.o'
  1277     AIX_TMP='./_aix_tmp.o'
  1278     if test -n "$USE_64"; then
  1279         MDCPUCFG_H=_aix64.cfg
  1280         OBJECT_MODE=64
  1281     else
  1282         MDCPUCFG_H=_aix32.cfg
  1283     fi
  1284     PR_MD_CSRCS=aix.c
  1285     RESOLVE_LINK_SYMBOLS=1
  1286     ;;
  1288 *-beos*)
  1289     AC_DEFINE(XP_BEOS)
  1290     AC_DEFINE(BeOS)
  1291     AC_DEFINE(BEOS)
  1292     AC_DEFINE(_POSIX_SOURCE)
  1293     DSO_LDOPTS=-nostart
  1294     MDCPUCFG_H=_beos.cfg
  1295     USE_BTHREADS=1
  1296     PR_MD_ARCH_DIR=beos
  1297     RESOLVE_LINK_SYMBOLS=1
  1298     case "${target_cpu}" in
  1299     i*86)
  1300         _OPTIMIZE_FLAGS=-O2
  1301         _DEBUG_FLAGS='-gdwarf-2 -O0'
  1302         MKSHLIB='$(CCC) $(DSO_LDOPTS) -o $@'
  1303         AC_CHECK_LIB(bind, gethostbyaddr, [OS_LIBS="$OS_LIBS -lbind -lsocket"])
  1304         ;;
  1305     powerpc)
  1306         CC=mwcc
  1307         CCC=mwcc
  1308         LD=mwld
  1309         DSO_LDOPTS='-xms -export pragma -init _init_routine_ -term _term_routine_ -lroot -lnet /boot/develop/lib/ppc/glue-noinit.a /boot/develop/lib/ppc/init_term_dyn.o /boot/develop/lib/ppc/start_dyn.o'
  1310         _OPTIMIZE_FLAGS=-O2    
  1311         _DEBUG_FLAGS='-g -O0'
  1312         ;;
  1313     esac
  1314     ;;
  1316 *-bsdi*)
  1317     AC_DEFINE(XP_UNIX)
  1318     AC_DEFINE(BSDI)
  1319     AC_DEFINE(NEED_BSDREGEX)
  1321     CFLAGS="$CFLAGS -Wall -Wno-format"
  1322     CXXFLAGS="$CXXFLAGS -Wall -Wno-format"
  1324     if echo "$OS_TEST" | grep -c 86 >/dev/null; then
  1325         CPU_ARCH=x86
  1326     elif echo "$OS_TEST" | grep -c sparc >/dev/null; then 
  1327         CPU_ARCH=sparc
  1328     fi
  1330     MDCPUCFG_H=_bsdi.cfg
  1331     PR_MD_CSRCS=bsdi.c
  1333     DSO_LDOPTS=-r
  1335     case "$target_os" in
  1336     bsdi1.1*)
  1337         AC_DEFINE(_PR_BSDI_JMPBUF_IS_ARRAY)
  1338         AC_DEFINE(_PR_STAT_HAS_ONLY_ST_ATIME)
  1339         AC_DEFINE(_PR_NEED_H_ERRNO)
  1340         MKSHLIB=
  1341         DSO_CFLAGS=
  1342         DSO_LDOPTS=
  1343         ;;
  1345     bsdi2.1*)
  1346         AC_DEFINE(_PR_TIMESPEC_HAS_TS_SEC)
  1347         AC_DEFINE(_PR_BSDI_JMPBUF_IS_ARRAY)
  1348         AC_DEFINE(HAVE_DLL)
  1349         AC_DEFINE(USE_DLFCN)
  1350         AC_DEFINE(_PR_STAT_HAS_ST_ATIMESPEC)
  1351         PR_MD_ASFILES=os_BSD_OS_386_2.s
  1352         ;;
  1354     bsdi4.* | bsdi5.*)
  1355         AC_DEFINE(_PR_SELECT_CONST_TIMEVAL)
  1356         AC_DEFINE(_PR_BSDI_JMPBUF_IS_STRUCT)
  1357         AC_DEFINE(HAVE_DLL)
  1358         AC_DEFINE(USE_DLFCN)
  1359         AC_DEFINE(_PR_STAT_HAS_ST_ATIMESPEC)
  1360         MKSHLIB='$(CC) -o $@ $(DSO_LDOPTS)'
  1361         DSO_CFLAGS=-fPIC
  1362         DSO_LDOPTS='-shared -Wl,-soname,$(@:$(OBJDIR)/%.so=%.so)'
  1363         STRIP="$STRIP -d"
  1364         case "$target_os" in
  1365         bsdi4.2* | bsdi4.3* | bsdi5.*)
  1366             AC_DEFINE(_PR_HAVE_GETPROTO_R)
  1367             AC_DEFINE(_PR_HAVE_GETPROTO_R_POINTER)
  1368             ;;
  1369         esac
  1370         ;;
  1371     *)
  1372         AC_DEFINE(_PR_SELECT_CONST_TIMEVAL)
  1373         AC_DEFINE(_PR_BSDI_JMPBUF_IS_STRUCT)
  1374         AC_DEFINE(HAVE_DLL)
  1375         AC_DEFINE(USE_DLFCN)
  1376         AC_DEFINE(_PR_STAT_HAS_ST_ATIMESPEC)
  1377         ;;
  1378     esac
  1380     ;;
  1382 *-darwin*)
  1383     AC_DEFINE(XP_UNIX)
  1384     AC_DEFINE(DARWIN)
  1385     AC_DEFINE(HAVE_BSD_FLOCK)
  1386     AC_DEFINE(HAVE_SOCKLEN_T)
  1387     AS='$(CC) -x assembler-with-cpp'
  1388     CFLAGS="$CFLAGS -Wall -fno-common"
  1389     case "${target_cpu}" in
  1390         arm*)
  1391             CPU_ARCH=arm
  1392             ;;
  1393         i*86*|x86_64)
  1394             if test -n "$USE_64"; then
  1395                 CPU_ARCH=x86_64
  1396             else        
  1397                 CPU_ARCH=i386
  1398             fi
  1399             ;;
  1400         *)
  1401             CPU_ARCH=ppc
  1402             ;;
  1403     esac
  1404     if test "`echo $CC | grep -c '\-arch '`" = "0"; then
  1405         CC="$CC -arch $CPU_ARCH"
  1406     fi
  1407     AC_CHECK_HEADER(crt_externs.h)
  1408     DSO_CFLAGS=-fPIC
  1409     DSO_LDOPTS='-dynamiclib -compatibility_version 1 -current_version 1 -all_load -install_name @executable_path/$@ -headerpad_max_install_names'
  1410     _OPTIMIZE_FLAGS=-O2
  1411     MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
  1412     STRIP="$STRIP -x -S"
  1413     DLL_SUFFIX=dylib
  1414     USE_PTHREADS=1
  1415     MDCPUCFG_H=_darwin.cfg
  1416     PR_MD_CSRCS=darwin.c
  1417     PR_MD_ASFILES=os_Darwin.s
  1419     # Add Mac OS X support for loading CFM & CFBundle plugins
  1420     if test -f "${MACOS_SDK_DIR}/System/Library/Frameworks/Carbon.framework/Carbon"; then
  1421         AC_DEFINE(XP_MACOSX)
  1422         OS_TARGET=MacOSX
  1424         if test -n "$_MACOSX_DEPLOYMENT_TARGET" ; then
  1425             dnl Use the specified value
  1426             export MACOSX_DEPLOYMENT_TARGET=$_MACOSX_DEPLOYMENT_TARGET
  1427         elif test -z "$MACOSX_DEPLOYMENT_TARGET" ; then
  1428             dnl No value specified on the command line or in the environment,
  1429             dnl use the lesser of the library's minimum or the architecture's
  1430             dnl minimum.
  1431             case "${target_cpu}" in
  1432                 powerpc*)
  1433                     dnl Architecture minimum 10.2
  1434                     export MACOSX_DEPLOYMENT_TARGET=10.2
  1435                     ;;
  1436                 i*86*)
  1437                     dnl Architecture minimum 10.4
  1438                     export MACOSX_DEPLOYMENT_TARGET=10.4
  1439                     ;;
  1440             esac
  1441         fi
  1443         dnl MACOS_SDK_DIR will be set to the SDK location whenever one is
  1444         dnl in use.  NEXT_ROOT will be set and exported if it's needed for
  1445         dnl ld.
  1447         if test "$MACOS_SDK_DIR"; then
  1448             dnl Sync this section with the one in Mozilla's top level.
  1450             if test ! -d "$MACOS_SDK_DIR"; then
  1451                 AC_MSG_ERROR([SDK not found.  When using --with-macos-sdk, you must
  1452 specify a valid SDK.  SDKs are installed when the optional cross-development
  1453 tools are selected during the Xcode/Developer Tools installation.])
  1454             fi
  1456             changequote(,)
  1457             CC_VERSION=`$CC -v 2>&1 | grep 'gcc version'`
  1458             GCC_VERSION_FULL=`echo $CC_VERSION | $PERL -pe 's/^.*gcc version ([^ ]*).*/$1/'`
  1459             GCC_VERSION=`echo $GCC_VERSION_FULL | $PERL -pe '(split(/\./))[0]>=4&&s/(^\d*\.\d*).*/$1/;'`
  1460             changequote([,])
  1461             GCC_VERSION_MAJOR=`echo $GCC_VERSION_FULL | $PERL -pe 's/(^\d*).*/$1/;'`
  1462             if test "$GCC_VERSION_MAJOR" -lt "4" ; then
  1463                 SDK_C_FRAMEWORK="-F${MACOS_SDK_DIR}/System/Library/Frameworks"
  1464                 if test -d "${MACOS_SDK_DIR}/Library/Frameworks" ; then
  1465                     SDK_C_FRAMEWORK="$SDK_C_FRAMEWORK -F${MACOS_SDK_DIR}/Library/Frameworks"
  1466                 fi
  1468                 SDK_C_INCLUDE="-isystem ${MACOS_SDK_DIR}/usr/include/gcc/darwin/${GCC_VERSION} -isystem ${MACOS_SDK_DIR}/usr/include ${SDK_C_FRAMEWORK}"
  1470                 CFLAGS="$CFLAGS -nostdinc ${SDK_C_INCLUDE}"
  1472                 dnl CPP needs to be set for AC_CHECK_HEADER.
  1473                 CPP="$CPP -nostdinc ${SDK_C_INCLUDE}"
  1475                 changequote(,)
  1476                 HOST_DARWIN_MAJOR=`echo "$build_os" | sed -E -e 's/^darwin([0-9]+).*$/\1/'`
  1477                 changequote([,])
  1478                 if test "$HOST_DARWIN_MAJOR" -lt 9 ; then
  1479                     dnl The build host is running Tiger (10.4) or earlier.
  1480                     dnl ld support for -syslibroot is compiler-agnostic, but
  1481                     dnl only available on Tiger and later.  On Tiger and
  1482                     dnl earlier build hosts, just rely on NEXT_ROOT, because
  1483                     dnl it's not been shown to cause any problems.
  1484                     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}"
  1485                 else
  1486                     dnl The build host is running Leopard (10.5) or later.
  1487                     dnl With NEXT_ROOT set, the linker will still not apply
  1488                     dnl it when resolving dependencies.  This causes problems
  1489                     dnl on Leopard, where an SDK depends on frameworks which
  1490                     dnl were present in earlier OS releases (and the associated
  1491                     dnl SDK) but not in Leopard.  -syslibroot does not have
  1492                     dnl this problem, but it results in harmless warnings when
  1493                     dnl NEXT_ROOT is set.  NEXT_ROOT needs to remain set even
  1494                     dnl on Leopard because the compiler uses it too.
  1495                     MACOS_SDK_LIBS="-Wl,-syslibroot,${MACOS_SDK_DIR}"
  1496                 fi
  1498                 LDFLAGS="${MACOS_SDK_LIBS} $LDFLAGS"
  1499                 export NEXT_ROOT=$MACOS_SDK_DIR
  1501                 if test -n "$CROSS_COMPILE" ; then
  1502                     dnl NEXT_ROOT will be in the environment, but it
  1503                     dnl shouldn't be set for the build host.  HOST_CXX is
  1504                     dnl presently unused.
  1505                     HOST_CC="NEXT_ROOT= $HOST_CC"
  1506                     HOST_CXX="NEXT_ROOT= $HOST_CXX"
  1507                 fi
  1508             else
  1509                 dnl gcc >= 4.0 uses different paths than above, but knows
  1510                 dnl how to find them itself.
  1511                 CFLAGS="$CFLAGS -isysroot ${MACOS_SDK_DIR}"
  1513                 dnl CPP needs to be set for AC_CHECK_HEADER.
  1514                 CPP="$CPP -isysroot ${MACOS_SDK_DIR}"
  1516                 dnl If gcc >= 4.0.0, we're guaranteed to be on Tiger, which
  1517                 dnl has an ld that supports -syslibroot.  Don't set
  1518                 dnl NEXT_ROOT because it will be ignored and cause
  1519                 dnl warnings when -syslibroot is specified.
  1520                 if test "$GCC_VERSION_FULL" != "4.0.0" ; then
  1521                     dnl gcc > 4.0.0 will pass -syslibroot to ld automatically
  1522                     dnl based on the -isysroot it receives.
  1523                     LDFLAGS="$LDFLAGS -isysroot ${MACOS_SDK_DIR}"
  1524                 else
  1525                     dnl gcc 4.0.0 doesn't pass -syslibroot to ld, it needs
  1526                     dnl to be explicit.
  1527                     LDFLAGS="$LDFLAGS -Wl,-syslibroot,${MACOS_SDK_DIR}"
  1528                 fi
  1529             fi
  1530         fi
  1531     fi
  1532     ;;
  1534 *-dgux*)
  1535     AC_DEFINE(XP_UNIX)
  1536     AC_DEFINE(_PR_LOCAL_THREADS_ONLY)
  1537     AC_DEFINE(SVR4)
  1538     AC_DEFINE(SYSV)
  1539     AC_DEFINE(DGUX)
  1540     AC_DEFINE(_DGUX_SOURCE)
  1541     AC_DEFINE(_POSIX4A_DRAFT6_SOURCE)
  1542     DSO_LDOPTS=-G
  1543     _OPTIMIZE_FLAGS=-O2
  1544     _DEBUG_FLAGS=
  1545     MDCPUCFG_H=_dgux.cfg
  1546     PR_MD_CSRCS=dgux.c
  1547     ;;
  1549 *-freebsd*)
  1550     if test -z "$USE_NSPR_THREADS"; then
  1551         USE_PTHREADS=1
  1552     fi
  1553     AC_DEFINE(XP_UNIX)
  1554     AC_DEFINE(FREEBSD)
  1555     AC_DEFINE(HAVE_BSD_FLOCK)
  1556     AC_DEFINE(HAVE_SOCKLEN_T)
  1557     CFLAGS="$CFLAGS $(DSO_CFLAGS) -ansi -Wall"
  1558     MOZ_OBJFORMAT=`test -x /usr/bin/objformat && /usr/bin/objformat || echo elf`
  1559     if test "$MOZ_OBJFORMAT" = "elf"; then
  1560         DLL_SUFFIX=so
  1561     else
  1562         DLL_SUFFIX=so.1.0
  1563     fi
  1564     MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
  1565     DSO_CFLAGS=-fPIC
  1566     DSO_LDOPTS='-shared -Wl,-soname -Wl,$(notdir $@)'
  1567     MDCPUCFG_H=_freebsd.cfg
  1568     PR_MD_CSRCS=freebsd.c
  1569     ;;
  1571 *-hpux*)
  1572     AC_DEFINE(XP_UNIX)
  1573     AC_DEFINE(HPUX)
  1574     AC_DEFINE(_HPUX_SOURCE)
  1575     # OSF1 and HPUX report the POLLHUP event for a socket when the
  1576     # shutdown(SHUT_WR) operation is called for the remote end, even though
  1577     # the socket is still writeable. Use select(), instead of poll(), to
  1578     # workaround this problem.
  1579     AC_DEFINE(_PR_POLL_WITH_SELECT)
  1580     AC_DEFINE(_USE_BIG_FDS)
  1581     DSO_LDOPTS='-b +h $(notdir $@)'
  1582     PR_MD_CSRCS=hpux.c
  1583     if test "$OS_TEST" = "ia64"; then
  1584         DLL_SUFFIX=so
  1585         DSO_LDOPTS="$DSO_LDOPTS +b '\$\$ORIGIN'"
  1586         CPU_ARCH_TAG=_$OS_TEST 
  1587         if test -z "$USE_64"; then
  1588             COMPILER_TAG=_32
  1589         fi
  1590         PR_MD_ASFILES=os_HPUX_ia64.s
  1591     else
  1592         AC_DEFINE(hppa)
  1593         DLL_SUFFIX=sl
  1594         PR_MD_ASFILES=os_HPUX.s
  1595     fi
  1596     if test -n "$USE_64"; then
  1597         MDCPUCFG_H=_hpux64.cfg
  1598     else
  1599         MDCPUCFG_H=_hpux32.cfg
  1600     fi
  1601     if test -z "$GNU_CC"; then
  1602         CC="$CC -Ae"
  1603         CXX="$CXX -ext"
  1604         DSO_CFLAGS=+Z
  1605     else
  1606         DSO_CFLAGS=-fPIC
  1607         ASFLAGS="$ASFLAGS -x assembler-with-cpp"
  1608     fi
  1610     if test -n "$MOZILLA_CLIENT"; then
  1611         DEFAULT_IMPL_STRATEGY=_EMU
  1612     fi
  1614     if echo "$OS_RELEASE" | grep ^A.09 >/dev/null; then
  1615         AC_DEFINE(_PR_NEED_H_ERRNO)
  1616         AC_DEFINE(HPUX9)
  1617         DEFAULT_IMPL_STRATEGY=_EMU
  1618     	USE_NSPR_THREADS=1
  1619     fi
  1621     if echo "$OS_RELEASE" | egrep '^(A.09|B.10)' >/dev/null; then
  1622         AC_DEFINE(_PR_NO_LARGE_FILES)
  1623     fi
  1625     if echo "$OS_RELEASE" | egrep '^(B.10.10|B.10.20)' >/dev/null; then
  1626         AC_DEFINE(_PR_NEED_H_ERRNO)
  1627     fi
  1629     if echo "$OS_RELEASE" | egrep '^(B.10.10|B.10.20)' >/dev/null; then
  1630         AC_DEFINE(HAVE_INT_LOCALTIME_R)
  1631     fi
  1633     if echo "$OS_RELEASE" | egrep '^(B.10.30|B.11)' >/dev/null; then
  1634         AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
  1635     fi
  1637     # HP-UX 11i v2 (B.11.23) or higher
  1638     changequote(<<,>>)
  1639     case "$OS_RELEASE" in
  1640     [C-Z]*|B.[2-9]*|B.1[2-9]*|B.11.[3-9]*|B.11.2[3-9]*)
  1641         USE_IPV6=1
  1642         ;;
  1643     esac
  1644     changequote([,])
  1646     if test "$OS_RELEASE" = "B.10.01"; then
  1647         AC_DEFINE(HPUX10)
  1648         DEFAULT_IMPL_STRATEGY=_EMU
  1649     fi
  1651     if test "$OS_RELEASE" = "B.10.10"; then
  1652         AC_DEFINE(HPUX10)
  1653         AC_DEFINE(HPUX10_10)
  1654         DEFAULT_IMPL_STRATEGY=_PTH
  1655     fi
  1657     if test "$OS_RELEASE" = "B.10.20"; then
  1658         AC_DEFINE(HPUX10)
  1659         AC_DEFINE(HPUX10_20)
  1660         if test -z "$GNU_CC"; then
  1661             CFLAGS="$CFLAGS +DAportable +DS1.1"
  1662             CXXFLAGS="$CXXFLAGS +DAportable +DS1.1"
  1663         fi
  1664         DEFAULT_IMPL_STRATEGY=_PTH
  1665     fi
  1667     if test "$OS_RELEASE" = "B.10.30"; then
  1668         AC_DEFINE(HPUX10)
  1669         AC_DEFINE(HPUX10_30)
  1670         if test -z "$GNU_CC"; then
  1671             CFLAGS="$CFLAGS +DAportable +DS1.1"
  1672             CXXFLAGS="$CXXFLAGS +DAportable +DS1.1"
  1673         fi
  1674         DEFAULT_IMPL_STRATEGY=_PTH
  1675     fi
  1677     if echo "$OS_RELEASE" | grep ^B.11 >/dev/null; then
  1678         AC_DEFINE(HPUX10)
  1679         AC_DEFINE(HPUX11)
  1680         AC_DEFINE(_LARGEFILE64_SOURCE)
  1681         AC_DEFINE(_PR_HAVE_OFF64_T)
  1682         AC_DEFINE(HAVE_FCNTL_FILE_LOCKING)
  1683         if test -z "$GNU_CC"; then
  1684             if test -z "$USE_64"; then
  1685                 if test "$OS_TEST" = "ia64"; then
  1686                     CFLAGS="$CFLAGS +DD32"
  1687                     CXXFLAGS="$CXXFLAGS +DD32"
  1688                 else
  1689                     CFLAGS="$CFLAGS +DAportable +DS2.0"
  1690                     CXXFLAGS="$CXXFLAGS +DAportable +DS2.0"
  1691                 fi
  1692             else
  1693                 if test "$OS_TEST" = "ia64"; then
  1694                     CFLAGS="$CFLAGS +DD64"
  1695                     CXXFLAGS="$CXXFLAGS +DD64"
  1696                 else
  1697                     CFLAGS="$CFLAGS +DA2.0W +DS2.0"
  1698                     CXXFLAGS="$CXXFLAGS +DA2.0W +DS2.0"
  1699                 fi
  1700             fi
  1701         fi
  1702         DEFAULT_IMPL_STRATEGY=_PTH
  1703     fi
  1705     if test "$DEFAULT_IMPL_STRATEGY" = "_EMU"; then
  1706         USE_NSPR_THREADS=1
  1707         USE_PTHREADS=
  1708         USE_USER_PTHREADS=
  1709     elif test "$DEFAULT_IMPL_STRATEGY" = "_PTH"; then
  1710         USE_PTHREADS=1
  1711         if test "$USE_NSPR_THREADS"; then
  1712             USE_PTHREADS=
  1713         fi
  1714         if test "$USE_USER_PTHREADS"; then
  1715             USE_PTHREADS=
  1716         fi
  1717     fi
  1718     ;;
  1720 *-irix*)
  1721     AC_DEFINE(XP_UNIX)
  1722     AC_DEFINE(IRIX)
  1723     AC_DEFINE(SVR4)
  1724     AC_DEFINE(_SGI_MP_SOURCE)
  1725     AC_DEFINE(HAVE_FCNTL_FILE_LOCKING)
  1726     PR_MD_CSRCS=irix.c
  1727     PR_MD_ASFILES=os_Irix.s
  1728     MKSHLIB='$(LD) $(DSO_LDOPTS) -rdata_shared -shared -soname $(notdir $@) -o $@'
  1729     STRIP="$STRIP -f"
  1730     RESOLVE_LINK_SYMBOLS=1
  1731     if test -n "$USE_64"; then
  1732         MDCPUCFG_H=_irix64.cfg
  1733     else
  1734         MDCPUCFG_H=_irix32.cfg
  1735     fi
  1736     case "${target_os}" in
  1737     irix6*)
  1738         AC_DEFINE(IRIX6)
  1739         USE_PTHREADS=1
  1740         USE_N32=1
  1741         COMPILER_TAG=_n32
  1742         IMPL_STRATEGY=_PTH
  1743         ;;
  1744     irix5*)
  1745         AC_DEFINE(IRIX5)
  1746         USE_NSPR_THREADS=1
  1747         ;;
  1748     *)
  1749         USE_PTHREADS=1
  1750         USE_N32=1
  1751         ;;
  1752     esac
  1753     if test "$GNU_CC"; then
  1754         dnl
  1755         dnl If we are using gcc with native binutils, we need to
  1756         dnl suppress the
  1757         dnl #lineno "filename" num num
  1758         dnl lines, which confuse IRIX native as.  Add -Wp,-P to the
  1759         dnl gcc command line, which passes -P to the preprocessor.
  1760         dnl
  1761 	    AS='$(CC) -Wp,-P -x assembler-with-cpp -D_ASM -mips2 $(INCLUDES)'
  1762 	    CFLAGS="$CFLAGS -Wall -Wno-format"
  1763 	    _OPTIMIZE_FLAGS="-O6"
  1764     else
  1765 	    if test -n "$USE_N32"; then
  1766 		AS='as -D_ASM $(INCLUDES) -n32'
  1767 	    else
  1768 		AS='as -D_ASM $(INCLUDES)'
  1769 	    fi
  1770 	    CFLAGS="$CFLAGS -fullwarn -xansi"
  1771 	    if test "$USE_N32"; then
  1772 	        _OPTIMIZE_FLAGS="-O -OPT:Olimit=4000"
  1773 	    else
  1774 	        _OPTIMIZE_FLAGS="-O -Olimit 4000"
  1775 	    fi
  1776 	    if test "$USE_MDUPDATE"; then
  1777                 CFLAGS="$CFLAGS -MDupdate \$(DEPENDENCIES)"
  1778 	    fi
  1779 	    case "${target}" in
  1780 	    *-irix6.*)
  1781 	        CFLAGS="$CFLAGS -multigot"
  1782 	        DSO_LDOPTS="-no_unresolved"
  1783 	        if test "$USE_N32"; then
  1784 		        CFLAGS="$CFLAGS -n32 -woff 1209"
  1785 		        DSO_LDOPTS="$DSO_LDOPTS -n32"
  1786 	        else
  1787 		        if test "$USE_64"; then
  1788 		            CFLAGS="$CFLAGS -64"
  1789 		        else
  1790 		            CFLAGS="$CFLAGS -32"
  1791 		        fi
  1792 	        fi
  1793 	        ;;
  1794 	    *)
  1795 	        CFLAGS="$CFLAGS -xgot"
  1796 	        ;;
  1797 	    esac
  1798     fi
  1799     if test "${target_os}" = "irix5.3"; then
  1800 	    AC_DEFINE(IRIX5_3)
  1801     fi
  1802     case "${target_os}" in
  1803 	irix6.5)
  1804 	    if test -z "$GNU_CC"; then
  1805 		    CFLAGS="$CFLAGS -mips3"
  1806 	    fi
  1807 	    AC_DEFINE(_PR_HAVE_GETPROTO_R)
  1808 	    AC_DEFINE(_PR_HAVE_GETPROTO_R_POINTER)
  1809 	    AC_DEFINE(_PR_HAVE_SGI_PRDA_PROCMASK)
  1810 	    ;;
  1811 	irix5*)
  1812 	    ;;
  1813 	*)
  1814 	    AC_DEFINE(_PR_HAVE_SGI_PRDA_PROCMASK)
  1815 	    ;;
  1816 	esac
  1817     ;;
  1819 *-linux*|*-gnu*|*-k*bsd*-gnu|*-android*|*-linuxandroid*)
  1820     if test -z "$USE_NSPR_THREADS"; then
  1821         USE_PTHREADS=1
  1822         IMPL_STRATEGY=_PTH
  1823     fi
  1824     AC_DEFINE(XP_UNIX)
  1825     AC_DEFINE(_GNU_SOURCE)
  1826     AC_DEFINE(HAVE_FCNTL_FILE_LOCKING)
  1827     case "${target}" in
  1828     *-android*|*-linuxandroid*)
  1829         OS_TARGET=Android
  1830         AC_DEFINE(LINUX)
  1831         ;;
  1832     *-linux*)
  1833         AC_DEFINE(LINUX)
  1834         ;;
  1835     esac
  1836     CFLAGS="$CFLAGS -Wall"
  1837     CXXFLAGS="$CXXFLAGS -Wall"
  1838     MDCPUCFG_H=_linux.cfg
  1839     PR_MD_CSRCS=linux.c
  1840     MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
  1841     DSO_CFLAGS=-fPIC
  1842     DSO_LDOPTS='-shared -Wl,-soname -Wl,$(notdir $@)'
  1843     _OPTIMIZE_FLAGS=-O2
  1844     _DEBUG_FLAGS="-g -fno-inline"  # most people on linux use gcc/gdb, and that
  1845                                    # combo is not yet good at debugging inlined
  1846                                    # functions (even when using DWARF2 as the
  1847                                    # debugging format)
  1848     COMPILER_TAG=_glibc
  1849     if echo "$OS_TEST" | grep -c 86 >/dev/null; then
  1850         CPU_ARCH=x86
  1851     else
  1852         CPU_ARCH=$OS_TEST
  1853     fi
  1854     CPU_ARCH_TAG=_${CPU_ARCH}
  1855     case "${target_cpu}" in
  1856     alpha)
  1857         AC_DEFINE(_ALPHA_)
  1858         AC_DEFINE(__alpha)
  1859         CFLAGS="$CFLAGS -mieee"
  1860         CXXFLAGS="$CXXFLAGS -mieee"
  1861         ;;
  1862     i*86)
  1863         AC_DEFINE(i386)
  1864         PR_MD_ASFILES=os_Linux_x86.s
  1865         ;;
  1866     ia64)
  1867         PR_MD_ASFILES=os_Linux_ia64.s
  1868         ;;
  1869     x86_64)
  1870         if test -n "$USE_64"; then
  1871             PR_MD_ASFILES=os_Linux_x86_64.s
  1872         elif test -n "$USE_X32"; then
  1873             PR_MD_ASFILES=os_Linux_x86_64.s
  1874             CC="$CC -mx32"
  1875             CXX="$CXX -mx32"
  1876         else
  1877             AC_DEFINE(i386)
  1878             PR_MD_ASFILES=os_Linux_x86.s
  1879             CC="$CC -m32"
  1880             CXX="$CXX -m32"
  1881         fi
  1882         ;;
  1883     ppc|powerpc)
  1884         PR_MD_ASFILES=os_Linux_ppc.s
  1885         ;;
  1886     powerpc64)
  1887         if test -n "$USE_64"; then
  1888             CC="$CC -m64"
  1889             CXX="$CXX -m64"
  1890         else
  1891             PR_MD_ASFILES=os_Linux_ppc.s
  1892         fi
  1893         ;;
  1894     m68k)
  1895         CFLAGS="$CFLAGS -m68020-60"
  1896         CXXFLAGS="$CXXFLAGS -m68020-60"
  1897         ;;
  1898     esac    
  1899     ;;
  1901 *-mingw*|*-msys*|*-cygwin*|*-mks*)
  1902     AC_DEFINE(XP_PC)
  1903     AC_DEFINE(WIN32)
  1904     PR_MD_ARCH_DIR=windows
  1905     RESOLVE_LINK_SYMBOLS=1
  1907     if test -n "$GNU_CC"; then
  1908         CC="$CC -mwindows"
  1909         CXX="$CXX -mwindows"
  1910         DLL_SUFFIX=dll
  1911         MKSHLIB='$(CC) -shared -Wl,--export-all-symbols -Wl,--out-implib -Wl,$(IMPORT_LIBRARY) $(DLLBASE) -o $(subst $(OBJDIR)/,,$(SHARED_LIBRARY))'
  1912         RC=$WINDRES
  1913         # Use temp file for windres (bug 213281)
  1914         RCFLAGS='-O coff --use-temp-file'
  1915     else
  1916         CC=cl
  1917         CXX=cl
  1918         LD=link
  1919         AR='lib -NOLOGO -OUT:"$@"'
  1920         AR_FLAGS=
  1921         RANLIB='echo not_ranlib'
  1922         STRIP='echo not_strip'
  1923         RC=rc.exe
  1924         GARBAGE='$(OBJDIR)/vc20.pdb $(OBJDIR)/vc40.pdb'
  1925         OBJ_SUFFIX=obj
  1926         LIB_SUFFIX=lib
  1927         DLL_SUFFIX=dll
  1929         # Determine compiler version
  1930         changequote(,)
  1931         _MSVC_VER_FILTER='s|.* \([0-9]\+\.[0-9]\+\.[0-9]\+\(\.[0-9]\+\)\?\).*|\1|p'
  1932         changequote([,])
  1933         CC_VERSION=`"${CC}" -v 2>&1 | sed -ne "$_MSVC_VER_FILTER"`
  1934         _CC_MAJOR_VERSION=`echo ${CC_VERSION} | awk -F\. '{ print $1 }'`
  1935         _CC_MINOR_VERSION=`echo ${CC_VERSION} | awk -F\. '{ print $2 }'`
  1936         _CC_RELEASE=`echo ${CC_VERSION} | awk -F\. '{ print $3 }'`
  1937         _CC_BUILD=`echo ${CC_VERSION} | awk -F\. '{ print $4 }'`
  1938         MSC_VER=${_CC_MAJOR_VERSION}${_CC_MINOR_VERSION}
  1940         if test "$_CC_MAJOR_VERSION" -eq "14"; then
  1941            dnl -DYNAMICBASE is only supported on VC8SP1 or newer,
  1942            dnl so be very specific here!
  1943            dnl VC8 is 14.00.50727.42, VC8SP1 is 14.00.50727.762
  1944            if test $_CC_RELEASE -gt 50727; then
  1945               _USE_DYNAMICBASE=1
  1946            elif test $_CC_BUILD -ge 762; then
  1947               _USE_DYNAMICBASE=1
  1948            fi
  1949            AC_DEFINE(_CRT_SECURE_NO_DEPRECATE)
  1950            AC_DEFINE(_CRT_NONSTDC_NO_DEPRECATE)
  1951         elif test $_CC_MAJOR_VERSION -ge 15; then
  1952            _USE_DYNAMICBASE=1    
  1953            AC_DEFINE(_CRT_SECURE_NO_WARNINGS)
  1954            AC_DEFINE(_CRT_NONSTDC_NO_WARNINGS)
  1955         fi
  1957         if test -n "$_USE_DYNAMICBASE"; then
  1958            DLLFLAGS="$DLLFLAGS -DYNAMICBASE"
  1959         fi
  1961         # Ensure that mt is Microsoft (R) Manifest Tool and not magnetic
  1962         # tape manipulation utility (or something else)
  1963         if test "$MSC_VER" -ge "1400"; then
  1964             changequote(,)
  1965             _MSMT_VER_FILTER='s|.* \([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*|\1|p'
  1966             changequote([,])
  1968             MSMT_TOOL=`mt 2>&1|grep 'Microsoft (R) Manifest Tool'`
  1969             if test -n "$MSMT_TOOL"; then
  1970                 MSMANIFEST_TOOL_VERSION=`echo ${MSMT_TOOL}|sed -ne "$_MSMT_VER_FILTER"`
  1971                 if test -z "$MSMANIFEST_TOOL_VERSION"; then
  1972                     AC_MSG_WARN([Unknown version of the Microsoft (R) Manifest Tool.])
  1973                 fi
  1974                 MT=mt
  1975                 unset MSMT_TOOL
  1976             else
  1977                 AC_MSG_ERROR([Microsoft (R) Manifest Tool must be in your \$PATH.])
  1978             fi
  1979         fi
  1981         CFLAGS="$CFLAGS -W3 -nologo -GF -Gy"
  1982         DLLFLAGS="$DLLFLAGS -OUT:\"\$@\""
  1983         _DEBUG_FLAGS=-Zi
  1984         _OPTIMIZE_FLAGS=-O2
  1986         PROFILE_GEN_CFLAGS="-GL"
  1987         PROFILE_GEN_LDFLAGS="-LTCG:PGINSTRUMENT"
  1988         PROFILE_USE_CFLAGS="-GL -wd4624 -wd4952"
  1989         PROFILE_USE_LDFLAGS="-LTCG:PGUPDATE"
  1991         if test "$MSC_VER" -ge "1800"; then
  1992             dnl Visual C++ 2013 requires -FS when parallel building with
  1993             dnl make -jN. If not specified, compiler sometimes emits C1041
  1994             dnl error.
  1995             CFLAGS="$CFLAGS -FS"
  1996             dnl -Gw can benefit when using linker optimization on PGO.
  1997             dnl http://blogs.msdn.com/b/vcblog/archive/2013/09/11/introducing-gw-compiler-switch.aspx
  1998             PROFILE_GEN_CFLAGS="$PROFILE_GEN_CFLAGS -Gw"
  1999             PROFILE_USE_CFLAGS="$PROFILE_USE_CFLAGS -Gw"
  2000         fi
  2002         if test -z "$MOZ_OPTIMIZE"; then
  2003             CFLAGS="$CFLAGS -Od"
  2004         fi
  2006         if test "$USE_DEBUG_RTL" = 1; then
  2007             CFLAGS="$CFLAGS -MDd"
  2008         else
  2009             CFLAGS="$CFLAGS -MD"
  2010         fi
  2012         if test -n "$MOZ_DEBUG"; then
  2013             AC_DEFINE(_DEBUG)
  2014         else
  2015             DEFINES="$DEFINES -U_DEBUG"
  2016         fi
  2018         if test -n "$MOZ_DEBUG_SYMBOLS"; then
  2019             if test -n "$MOZ_OPTIMIZE"; then
  2020                 DLLFLAGS="$DLLFLAGS -DEBUG -OPT:REF"
  2021                 LDFLAGS="$LDFLAGS -DEBUG -OPT:REF"
  2022             else
  2023                 DLLFLAGS="$DLLFLAGS -DEBUG"
  2024                 LDFLAGS="$LDFLAGS -DEBUG"
  2025             fi
  2026         fi
  2028         OS_DLLFLAGS="-nologo -DLL -SUBSYSTEM:WINDOWS"
  2029         if test "$MSC_VER" -le "1200" -a -z "$MOZ_DEBUG_SYMBOLS"; then
  2030             OS_DLLFLAGS="$OS_DLLFLAGS -PDB:NONE"
  2031         fi
  2033         if test "$OS_TARGET" = "WINNT"; then
  2034             CFLAGS="$CFLAGS -GT"
  2035             LIBNSPR='$(dist_libdir)/libnspr$(MOD_MAJOR_VERSION).$(LIB_SUFFIX)'
  2036             LIBPLC='$(dist_libdir)/libplc$(MOD_MAJOR_VERSION).$(LIB_SUFFIX)'
  2037         else
  2038             LIBNSPR='$(dist_libdir)/nspr$(MOD_MAJOR_VERSION).$(LIB_SUFFIX)'
  2039             LIBPLC='$(dist_libdir)/plc$(MOD_MAJOR_VERSION).$(LIB_SUFFIX)'
  2040         fi
  2041     fi # GNU_CC
  2043     if test -n "$USE_STATIC_TLS"; then
  2044         AC_DEFINE(_PR_USE_STATIC_TLS)
  2045     fi
  2047     if test "$OS_TARGET" = "WINNT"; then
  2048         AC_DEFINE(WINNT)
  2049     else
  2050         AC_DEFINE(WIN95)
  2051         # undefine WINNT as some versions of mingw gcc define it by default
  2052         DEFINES="$DEFINES -UWINNT"
  2053         AC_DEFINE(_PR_GLOBAL_THREADS_ONLY)
  2054     fi
  2056     if test "$CPU_ARCH" = "x86"; then
  2057         CPU_ARCH_TAG=
  2058     else
  2059         CPU_ARCH_TAG=$CPU_ARCH
  2060     fi
  2062     if test "$USE_DEBUG_RTL" = 1; then
  2063         OBJDIR_SUFFIX=OBJD
  2064     fi
  2066     case "$OS_TARGET" in
  2067     WINNT)
  2068 	    MDCPUCFG_H=_winnt.cfg
  2069 	    ;;
  2070     WIN95)
  2071 	    MDCPUCFG_H=_win95.cfg
  2072 	    ;;
  2073     *)
  2074 	    AC_MSG_ERROR([Missing OS_TARGET for ${target}.  Use --enable-win32-target to set.])
  2075    	;;
  2076     esac
  2078     case "$target_cpu" in
  2079     i*86)
  2080 	if test -n "$USE_64"; then
  2081 	    AC_DEFINE(_AMD64_)
  2082 	else		
  2083 	    AC_DEFINE(_X86_)
  2084 	fi
  2085         ;;
  2086     x86_64)
  2087 	    AC_DEFINE(_AMD64_)
  2088 	    USE_64=1
  2089 	    ;;
  2090     ia64)
  2091 	    AC_DEFINE(_IA64_)
  2092 	    USE_64=1
  2093 	    ;;
  2094     *)
  2095 	    AC_DEFINE(_CPU_ARCH_NOT_DEFINED)
  2096 	    ;;
  2097     esac
  2098     ;;
  2100 *-netbsd*)
  2101     AC_DEFINE(XP_UNIX)
  2102     AC_DEFINE(NETBSD)
  2103     AC_DEFINE(HAVE_BSD_FLOCK)
  2104     if test -z "$USE_NSPR_THREADS"; then
  2105         USE_PTHREADS=1
  2106     fi
  2107     MDCPUCFG_H=_netbsd.cfg
  2108     PR_MD_CSRCS=netbsd.c
  2110     DSO_CFLAGS='-fPIC -DPIC'
  2111     CFLAGS="$CFLAGS -ansi -Wall"
  2112     CXXFLAGS="$CXXFLAGS -ansi -Wall"
  2113     MKSHLIB='$(CC) -o $@ $(DSO_LDOPTS)'
  2115     if test -z "$OBJECT_FMT"; then
  2116         if echo __ELF__ | ${CC-cc} -E - | grep -q __ELF__ 2>/dev/null; then
  2117             OBJECT_FMT=a.out
  2118             DLL_SUFFIX=so.1.0
  2119             DSO_LDOPTS='-shared'
  2120         else
  2121             OBJECT_FMT=ELF
  2122             DLL_SUFFIX=so
  2123             DSO_LDOPTS='-shared -Wl,-soname,$(notdir $@)'
  2124         fi
  2125     fi
  2127     if test "$LIBRUNPATH"; then
  2128         DSO_LDOPTS="$DSO_LDOPTS -Wl,-R$LIBRUNPATH"
  2129     fi
  2130     ;;
  2132 *-nto*)
  2133     AC_DEFINE(XP_UNIX)
  2134     AC_DEFINE(NTO)
  2135     AC_DEFINE(_QNX_SOURCE)
  2136     AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
  2137     MDCPUCFG_H=_nto.cfg
  2138     PR_MD_CSRCS=nto.c
  2139     MKSHLIB='$(CC) $(DSO_LDOPTS) -Wl,-soname -Wl,$(notdir $@) -o $@'
  2140     DSO_CFLAGS=-fPIC
  2141     DSO_LDOPTS=-shared
  2142     OS_LIBS="$OS_LIBS -lsocket"
  2143     _OPTIMIZE_FLAGS="-O1"
  2144     _DEBUG_FLAGS="-gstabs"
  2145 	;;
  2147 *-openbsd*)
  2148     AC_DEFINE(XP_UNIX)
  2149     AC_DEFINE(OPENBSD)
  2150     AC_DEFINE(HAVE_BSD_FLOCK)
  2151     AC_DEFINE(HAVE_SOCKLEN_T)
  2152     CFLAGS="$CFLAGS -ansi -Wall"
  2153     CXXFLAGS="$CXXFLAGS -ansi -Wall"
  2154     DLL_SUFFIX=so.1.0
  2155     DSO_CFLAGS=-fPIC
  2156     MDCPUCFG_H=_openbsd.cfg
  2157     PR_MD_CSRCS=openbsd.c
  2158     OS_LIBS="-lc"
  2159     if test -z "$USE_NSPR_THREADS"; then
  2160         USE_PTHREADS=1
  2161     fi
  2162     DSO_LDOPTS='-shared -fPIC'
  2163     MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
  2164     ;;
  2166 *-osf*)
  2167     SHELL_OVERRIDE="SHELL		= /usr/bin/ksh"
  2168     AC_DEFINE(XP_UNIX)
  2169     AC_DEFINE(OSF1)
  2170     AC_DEFINE(_REENTRANT)
  2171     # OSF1 and HPUX report the POLLHUP event for a socket when the
  2172     # shutdown(SHUT_WR) operation is called for the remote end, even though
  2173     # the socket is still writeable. Use select(), instead of poll(), to
  2174     # workaround this problem.
  2175     AC_DEFINE(_PR_POLL_WITH_SELECT)
  2177     if echo "$OS_RELEASE" | egrep -c '(V2.0|V3.2)' 2>/dev/null ; then
  2178         USE_NSPR_THREADS=1
  2179     fi
  2181     if test -z "$GNU_CC"; then
  2182         CC="$CC -std1 -ieee_with_inexact"
  2183         if test "$OS_RELEASE" != "V2.0"; then
  2184             CC="$CC -readonly_strings"
  2185         fi
  2186         _OPTIMIZE_FLAGS="$_OPTIMIZE_FLAGS -Olimit 4000"
  2187         AC_CHECK_HEADER(machine/builtins.h, AC_DEFINE(OSF1_HAVE_MACHINE_BUILTINS_H))
  2188     else
  2189         CFLAGS="$CFLAGS -mieee"
  2190         CXXFLAGS="$CXXFLAGS -mieee"
  2191     fi
  2193     if echo $OS_RELEASE | egrep -c '(V2.0|V3.2)' 2>/dev/null; then
  2194         AC_DEFINE(HAVE_INT_LOCALTIME_R)
  2195     else
  2196         AC_DEFINE(HAVE_FCNTL_FILE_LOCKING)
  2197         AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
  2198     fi
  2199     if echo $OS_RELEASE | grep -c V4.0 >/dev/null; then
  2200         AC_DEFINE(OSF1V4_MAP_PRIVATE_BUG)
  2201     fi
  2202     DSO_LDOPTS='-shared -all -expect_unresolved "*" -soname $(notdir $@)'
  2203     MDCPUCFG_H=_osf1.cfg
  2204     PR_MD_CSRCS=osf1.c
  2205     ;;
  2207 *-qnx*)
  2208     AC_DEFINE(XP_UNIX)
  2209     AC_DEFINE(QNX)
  2210     AC_DEFINE(_PR_NEED_H_ERRNO)
  2211     USE_NSPR_THREADS=1
  2212     MDCPUCFG_H=_qnx.cfg
  2213     PR_MD_CSRCS=qnx.c
  2214     ;;
  2216 *-riscos*)
  2217     AC_DEFINE(XP_UNIX)
  2218     AC_DEFINE(RISCOS)
  2219     AC_DEFINE(_PR_NEED_H_ERRNO)
  2220     USE_PTHREADS=1
  2221     MDCPUCFG_H=_riscos.cfg
  2222     PR_MD_CSRCS=riscos.c
  2223     DSO_CFLAGS=-fPIC
  2224     DSO_LDOPTS='-shared -Wl,-soname -Wl,$(notdir $@)'
  2225     MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
  2226     ;;
  2228 *-*-sco*)
  2229     AC_DEFINE(XP_UNIX)
  2230     AC_DEFINE(SCO)
  2231     AC_DEFINE(sco)
  2232     AC_DEFINE(SYSV)
  2233     AC_DEFINE(_SVID3)
  2234     AC_DEFINE(_PR_NEED_H_ERRNO)
  2235     CC='cc -b elf -KPIC'
  2236     CXX='$(NSDEPTH)/build/hcpp CC +.cpp +w'
  2237     USE_NSPR_THREADS=1
  2238     CPU_ARCH=x86
  2239     DSO_LDOPTS='-b elf -G'
  2240     MDCPUCFG_H=_scoos.cfg
  2241     PR_MD_SRCS=scoos.c
  2242     ;;
  2244 *-solaris*)
  2245     if test -z "$USE_NSPR_THREADS"; then
  2246         USE_PTHREADS=1
  2247     fi
  2248     AC_DEFINE(XP_UNIX)
  2249     AC_DEFINE(SVR4)
  2250     AC_DEFINE(SYSV)
  2251     AC_DEFINE(__svr4)
  2252     AC_DEFINE(__svr4__)
  2253     AC_DEFINE(SOLARIS)
  2254     AC_DEFINE(HAVE_FCNTL_FILE_LOCKING)
  2255     CPU_ARCH=`uname -p`
  2256     MDCPUCFG_H=_solaris.cfg
  2257     PR_MD_CSRCS=solaris.c
  2258     LD=/usr/ccs/bin/ld
  2259     MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
  2260     RESOLVE_LINK_SYMBOLS=1
  2261     case "${OS_RELEASE}" in
  2262     5.8|5.9)
  2263         ;;
  2264     *)
  2265         # It is safe to use the -Bdirect linker flag on Solaris 10 or later.
  2266         USE_B_DIRECT=1
  2267         ;;
  2268     esac
  2269     if test -n "$GNU_CC"; then
  2270         DSO_CFLAGS=-fPIC
  2271         if `$CC -print-prog-name=ld` -v 2>&1 | grep -c GNU >/dev/null; then
  2272             GCC_USE_GNU_LD=1
  2273         fi
  2274         DSO_LDOPTS='-shared -Wl,-h,$(notdir $@),-z,combreloc,-z,defs,-z,ignore' 
  2275         if test -n "$USE_B_DIRECT"; then
  2276             DSO_LDOPTS="$DSO_LDOPTS,-Bdirect"
  2277         fi
  2278     else
  2279         DSO_CFLAGS=-KPIC
  2280         DSO_LDOPTS='-G -h $(notdir $@) -z combreloc -z defs -z ignore'
  2281         if test -n "$USE_B_DIRECT"; then
  2282             DSO_LDOPTS="$DSO_LDOPTS -Bdirect"
  2283         fi
  2284     fi
  2285     if test -n "$GNU_CC"; then
  2286         CFLAGS="$CFLAGS -Wall"
  2287         CXXFLAGS="$CXXFLAGS -Wall"
  2288         if test -n "$USE_MDUPDATE"; then
  2289             CFLAGS="$CFLAGS -MDupdate \$(DEPENDENCIES)"
  2290             CXXFLAGS="$CXXFLAGS -MDupdate \$(DEPENDENCIES)"
  2291         fi
  2292         GCC_AS=`$CC -print-prog-name=as`
  2293         if test "`echo | $GCC_AS -v 2>&1 | grep -c GNU`" != "0"; then
  2294             GNU_AS=1
  2295         fi
  2296     else
  2297         CFLAGS="$CFLAGS -xstrconst"
  2298         CXXFLAGS="$CXXFLAGS -Qoption cg -xstrconst -features=tmplife"
  2299         if test -z "$MOZ_OPTIMIZE"; then
  2300             CFLAGS="$CFLAGS -xs"
  2301             CXXFLAGS="$CXXFLAGS -xs"
  2302         fi
  2303         _OPTIMIZE_FLAGS=-xO4
  2304     fi
  2305     if test -z "$GNU_AS"; then
  2306         ASFLAGS="$ASFLAGS -Wa,-P"
  2307     fi
  2308     if test -n "$USE_64"; then
  2309         if test -n "$GNU_CC"; then
  2310             CC="$CC -m64"
  2311             CXX="$CXX -m64"
  2312         else
  2313             if test "$OS_TEST" = "i86pc"; then
  2314                 CC="$CC -xarch=amd64"
  2315                 CXX="$CXX -xarch=amd64"
  2316             else
  2317                 CC="$CC -xarch=v9"
  2318                 CXX="$CXX -xarch=v9"
  2319             fi
  2320         fi
  2321     fi
  2322     if test "$OS_TEST" = "i86pc"; then
  2323         if test -z "$USE_64"; then
  2324             AC_DEFINE(i386)
  2325         fi
  2326         CPU_ARCH_TAG=_$OS_TEST
  2327         # The default debug format, DWARF (-g), is not supported by gcc
  2328         # on i386-ANY-sysv4/solaris, but the stabs format is.  It is
  2329         # assumed that the Solaris assembler /usr/ccs/bin/as is used.
  2330         # If your gcc uses GNU as, you do not need the -Wa,-s option.
  2331         if test -n "$MOZ_DEBUG" && test -n "$GNU_CC"; then
  2332             _DEBUG_FLAGS=-gstabs
  2333             if test -z "$GNU_AS"; then
  2334                 _DEBUG_FLAGS="$_DEBUG_FLAGS -Wa,-s"
  2335             fi
  2336         fi
  2337     fi
  2338     case "${target_os}" in
  2339     solaris2.3*)
  2340         AC_DEFINE(_PR_NO_LARGE_FILES)
  2341         ;;
  2342     solaris2.4*)
  2343         AC_DEFINE(_PR_NO_LARGE_FILES)
  2344         ;;
  2345     solaris2.5*)
  2346         AC_DEFINE(SOLARIS2_5)    
  2347         ;;
  2348     *)
  2349         AC_DEFINE(_PR_HAVE_OFF64_T)
  2350         # The lfcompile64(5) man page on Solaris 2.6 says:
  2351         #     For applications that do not wish to conform to the POSIX or
  2352         #     X/Open  specifications,  the  64-bit transitional interfaces
  2353         #     are available by default.  No compile-time flags need to  be
  2354         #     set.
  2355         # But gcc 2.7.2.x fails to define _LARGEFILE64_SOURCE by default.
  2356         # The native compiler, gcc 2.8.x, and egcs don't have this problem.
  2357         if test -n "$GNU_CC"; then
  2358             AC_DEFINE(_LARGEFILE64_SOURCE)
  2359         fi
  2360         ;;
  2361     esac
  2362     case "${target_os}" in
  2363     solaris2.3*)
  2364         ;;
  2365     solaris2.4*)
  2366         ;;
  2367     solaris2.5*)
  2368         ;;
  2369     solaris2.6*)
  2370         ;;
  2371     solaris2.7*)
  2372         ;;
  2373     *)
  2374         # Solaris 8 or higher has IPv6.
  2375         AC_DEFINE(_PR_INET6)
  2376         ;;
  2377     esac
  2378     if test "$CPU_ARCH" = "sparc"; then
  2379         # 64-bit Solaris SPARC requires V9 architecture, so the following
  2380         # is not needed.
  2381         if test -z "$USE_64"; then
  2382             ULTRASPARC_LIBRARY=nspr_flt
  2383         fi
  2384     fi
  2385     # Purify requires that binaries linked against nspr also
  2386     # be linked against -lrt (or -lposix4) so add it to OS_LIBS
  2387     _rev=`uname -r`
  2388     _librt=`echo $_rev 5.6 | awk '{ if ($1 > $2) print "-lrt"; else print "-lposix4" }'`
  2389     OS_LIBS="$OS_LIBS $_librt"
  2390     ;;
  2392 *-sco-sysv5*)
  2393     AC_DEFINE(XP_UNIX)
  2394     AC_DEFINE(UNIXWARE)
  2395     AC_DEFINE(SVR4)
  2396     AC_DEFINE(SYSV)
  2397     USE_NSPR_THREADS=1
  2398     if echo $OS_RELEASE | grep -c 2.1 2>/dev/null; then
  2399         AC_DEFINE(_PR_NO_LARGE_FILES)
  2400         CC='$(NSDEPTH)/build/hcc cc'
  2401         CXX='$(NSDEPTH)/build/hcpp CC'
  2402         MDCPUCFG_H=_unixware.cfg
  2403     else
  2404         AC_DEFINE(_LARGEFILE64_SOURCE)
  2405         AC_DEFINE(_PR_HAVE_OFF64_T)
  2406         AC_DEFINE(_PR_HAVE_SOCKADDR_LEN)
  2407         MDCPUCFG_H=_unixware7.cfg
  2408     fi
  2409     PR_MD_CSRCS=unixware.c
  2410     DSO_LDOPTS=-G
  2411     CPU_ARCH=x86
  2412     ;;
  2414 *-symbian*)
  2415     AC_ARG_WITH(symbian-sdk,
  2416     [  --with-symbian-sdk=SYMBIAN_SDK_DIR
  2417                           The path to the Symbian SDK],
  2418     SYMBIAN_SDK_DIR=$withval)
  2420     echo -----------------------------------------------------------------------------
  2421     echo Building with Symbian SDK in: $SYMBIAN_SDK_DIR
  2422     echo -----------------------------------------------------------------------------
  2424     AC_DEFINE(XP_UNIX)
  2425     AC_DEFINE(SYMBIAN)
  2426     AC_DEFINE(__arm__)
  2427     AC_DEFINE(__SYMBIAN32__)
  2428     AC_DEFINE(_UNICODE)
  2429     AC_DEFINE(NDEBUG)
  2430     AC_DEFINE(__SUPPORT_CPP_EXCEPTIONS__)
  2431     AC_DEFINE(MOZ_STDERR_TO_STDOUT)
  2432     AC_DEFINE(HAVE_FCNTL_FILE_LOCKING)
  2433     AC_DEFINE(HAVE_SOCKLEN_T)
  2434     USE_PTHREADS=1
  2435     LIB_SUFFIX=lib
  2436     DLL_SUFFIX=dll
  2437     MKSHLIB=
  2438     DSO_LDOPTS=
  2439     DSO_CFLAGS=
  2440     VISIBILITY_FLAGS=
  2441     MDCPUCFG_H=_symbian.cfg
  2442     PR_MD_CSRCS=symbian.c
  2443     NSINSTALL=nsinstall
  2444     RANLIB='echo no ranlib '
  2445     CPU_ARCH=ARM
  2446     OS_ARCH=SYMBIAN
  2447     OS_EXE_CFLAGS="$OS_EXE_CFLAGS -D__EXE__"
  2448     CFLAGS="$CFLAGS -MD -nostdinc"
  2449     SYMBIAN_SYS_INCLUDE="-I$SYMBIAN_SDK_DIR/Epoc32/include/variant -I$SYMBIAN_SDK_DIR/Epoc32/include -I$SYMBIAN_SDK_DIR/Epoc32/include/stdapis"
  2450     echo -------------------------------------------------------
  2451     echo SYMBIAN_SYS_INCLUDE is: $SYMBIAN_SYS_INCLUDE
  2452     echo -------------------------------------------------------
  2453     case "$OS_TARGET" in
  2454     WINSCW)
  2455         CC=mwccsym2.exe
  2456         CXX=mwccsym2.exe
  2457         LD=mwldsym2.exe
  2458         AR=mwldsym2.exe
  2459         WINSCW_LD_DIR="\$(SYMBIAN_SDK_DIR)/EPOC32/RELEASE/WINSCW/UDEB"
  2460         CFLAGS="$CFLAGS -O0 -inline off -wchar_t off -align 4 -warnings on -w nohidevirtual,nounusedexpr -msgstyle gcc -enum int -str pool -exc ms -trigraphs on -nostderr -gccdep -cwd source -i- -I\$(VPATH)"
  2461         SYMBIAN_SYS_INCLUDE="$SYMBIAN_SYS_INCLUDE -include Symbian_OS_v9.2.hrh"
  2462         AR_FLAGS="-library -msgstyle gcc -stdlib -subsystem windows -noimplib -o \$@"
  2463         AC_DEFINE(_DEBUG)
  2464         AC_DEFINE(__CW32__)
  2465         AC_DEFINE(__WINS__)
  2466         AC_DEFINE(__WINSCW__)
  2467         DEFINES="$DEFINES -U_WIN32"
  2468 	    ;;
  2469     GCCE)
  2470         CFLAGS="$CFLAGS -Wall -Wno-unknown-pragmas -fexceptions -march=armv5t -mapcs -pipe -x c -msoft-float"
  2471         CXXFLAGS="$CXXFLAGS $CFLAGS -Wno-ctor-dtor-privacy"
  2472         SYMBIAN_SYS_INCLUDE="$SYMBIAN_SYS_INCLUDE -include $SYMBIAN_SDK_DIR/EPOC32/INCLUDE/GCCE/GCCE.h"
  2473         AC_DEFINE(__GCCE__)
  2474         AC_DEFINE(__EABI__)
  2475         DEFINES="$DEFINES -D__PRODUCT_INCLUDE__=$SYMBIAN_SDK_DIR/Epoc32/include/variant/Symbian_OS_v9.2.hrh"
  2476 	    ;;
  2477     *)
  2478 	    AC_MSG_ERROR([Missing OS_TARGET for ${target}. Set --enable-symbian-target to with 'WINSCW' or 'GCCE'.])
  2479    	;;
  2480     esac
  2481     CFLAGS="$CFLAGS ${SYMBIAN_SYS_INCLUDE}"
  2482     ;;
  2484 *-os2*)
  2485     AC_DEFINE(XP_OS2)
  2486     AC_DEFINE(XP_PC)
  2487     AC_DEFINE(BSD_SELECT)
  2488     AC_DEFINE(TCPV40HDRS)
  2489     LIB_SUFFIX=lib
  2490     DLL_SUFFIX=dll
  2491     RC=rc.exe
  2492     PR_MD_ARCH_DIR=os2
  2493     PROG_SUFFIX=.exe
  2494     NSINSTALL=nsinstall
  2495     MDCPUCFG_H=_os2.cfg
  2496     RESOLVE_LINK_SYMBOLS=1
  2498     AC_DEFINE(OS2)
  2499     AR=emxomfar
  2500     AR_FLAGS='r $@'
  2501     CFLAGS="$CFLAGS -Wall -Zomf"
  2502     CXXFLAGS="$CFLAGS -Wall -Zomf"
  2503     MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
  2504     DSO_CFLAGS=
  2505     DSO_LDOPTS='-Zomf -Zdll'
  2506     LDFLAGS='-Zmap'
  2507     _OPTIMIZE_FLAGS="-O2 -s"
  2508     _DEBUG_FLAGS="-g -fno-inline"
  2509     if test -n "$MOZ_OPTIMIZE"; then
  2510       DSO_LDOPTS="$DSO_LDOPTS -Zlinker /EXEPACK:2 -Zlinker /PACKCODE -Zlinker /PACKDATA"
  2511     fi
  2512     IMPLIB='emximp -o'
  2513     FILTER='emxexp -o'
  2514     if test -n "$MOZ_OS2_HIGH_MEMORY"; then
  2515       LDFLAGS="$LDFLAGS -Zhigh-mem"
  2516       AC_DEFINE(MOZ_OS2_HIGH_MEMORY)
  2517     fi
  2519     # GCC for OS/2 currently predefines these, but we don't want them
  2520     DEFINES="$DEFINES -Uunix -U__unix -U__unix__"
  2521     ;;
  2523 *)
  2524     AC_DEFINE(XP_UNIX)
  2525     ;;
  2527 esac
  2529 if test -z "$SKIP_LIBRARY_CHECKS"; then
  2530 dnl ========================================================
  2531 dnl Check for system libraries
  2532 dnl ========================================================
  2535 dnl We don't want anything to link with libdl even if it's present on OS X, 
  2536 dnl since it's not used and not part of the default installation.
  2537 dnl The same goes for BeOS.
  2538 dnl OS/2 has dlfcn in libc.
  2540 case $target in
  2541 *-darwin*|*-beos*|*-os2*)
  2542     ;;
  2543 *)
  2544     AC_CHECK_LIB(dl, dlopen,
  2545         [AC_CHECK_HEADER(dlfcn.h,
  2546             OS_LIBS="-ldl $OS_LIBS")])
  2547     ;;
  2548 esac
  2551 dnl ========================================================
  2552 dnl Check for system header files.
  2553 dnl ========================================================
  2555 dnl ========================================================
  2556 dnl Check for typedefs and structs
  2557 dnl ========================================================
  2559 dnl ========================================================
  2560 dnl Checks for library functions.
  2561 dnl ========================================================
  2562 AC_PROG_GCC_TRADITIONAL
  2563 _SAVE_LIBS="$LIBS"
  2564 LIBS="$LIBS $OS_LIBS"
  2565 AC_CHECK_FUNCS(dladdr gettid lchown setpriority strerror syscall)
  2566 LIBS="$_SAVE_LIBS"
  2568 dnl ========================================================
  2569 dnl Check options
  2570 dnl ========================================================
  2572 dnl ======================================================
  2573 dnl = Enable compiling with ccache
  2574 dnl ======================================================
  2575 AC_ARG_WITH(ccache,
  2576 [  --with-ccache[=path/to/ccache]
  2577                           Enable compiling with ccache],
  2578     CCACHE=$withval, CCACHE="no")
  2580 if test "$CCACHE" != "no"; then
  2581     if test -n "$CCACHE"; then
  2582         if test "$CCACHE" = "yes"; then
  2583             CCACHE=
  2584         else
  2585             if test ! -e "$CCACHE"; then
  2586                 AC_MSG_ERROR([$CCACHE not found])
  2587             fi
  2588         fi
  2589     fi
  2590     AC_PATH_PROGS(CCACHE, $CCACHE ccache)
  2591     if test -z "$CCACHE" -o "$CCACHE" = ":"; then
  2592         AC_MSG_ERROR([ccache not found])
  2593     elif test -x "$CCACHE"; then
  2594         CC="$CCACHE $CC"
  2595         CXX="$CCACHE $CXX"
  2596     else
  2597         AC_MSG_ERROR([$CCACHE is not executable])
  2598     fi
  2599 fi
  2601 dnl ========================================================
  2602 dnl =
  2603 dnl = --enable-strip
  2604 dnl = 
  2605 dnl = Enable stripping of libs and executables
  2606 dnl = 
  2607 dnl ========================================================
  2608 AC_ARG_ENABLE(strip,
  2609     [  --enable-strip          Enable stripping of shared libs and programs],
  2610     [ if test "$enableval" = "yes"; then
  2611 	    ENABLE_STRIP=1
  2612       fi ])
  2614 dnl Check for hpux options
  2615 case "${target_os}" in
  2616 hpux*)
  2617 if test -z "$GNU_CC"; then
  2619     AC_CACHE_CHECK(for +Olit support,
  2620         ac_cv_hpux_usable_olit_option,
  2621         dnl since aCC doesn't throw an error on invalid options,
  2622         dnl we have to test this the hard way
  2623         [ac_cv_hpux_usable_olit_option=no
  2624         rm -f conftest*
  2625         echo 'int main() { return 0; }' | cat > conftest.c
  2626         ${CC-cc} ${CFLAGS} +Olit=all -o conftest conftest.c > conftest.out 2>&1
  2627         if test $? -eq 0; then
  2628             if test -z "`egrep -i '(unrecognize|unknown)' conftest.out`"; then
  2629                 ac_cv_hpux_usable_olit_option=yes
  2630             fi
  2631         fi
  2632         rm -f conftest*
  2633         ])
  2635     if test "$ac_cv_hpux_usable_olit_option" = "yes"; then
  2636         CFLAGS="$CFLAGS +Olit=all"
  2637         CXXFLAGS="$CXXFLAGS +Olit=all"
  2638     else
  2639         CFLAGS="$CFLAGS +ESlit"
  2640         CXXFLAGS="$CXXFLAGS +ESlit"
  2641     fi
  2642 fi
  2643 ;;
  2644 esac
  2646 dnl
  2647 dnl Apparently, some systems cannot properly check for the pthread
  2648 dnl library unless <pthread.h> is included so we need to test
  2649 dnl using it
  2650 dnl
  2651 dnl MOZ_CHECK_PTHREADS(lib, success, failure)
  2652 AC_DEFUN(MOZ_CHECK_PTHREADS,
  2654 AC_MSG_CHECKING([for pthread_create in -l$1])
  2655 echo "
  2656     #include <pthread.h> 
  2657     void *foo(void *v) { return v; } 
  2658     int main() { 
  2659         pthread_t t;
  2660         if (!pthread_create(&t, 0, &foo, 0)) {
  2661             pthread_join(t, 0);
  2663         return 0;
  2664     }" > dummy.c ;
  2665     echo "${CC-cc} -o dummy${ac_exeext} dummy.c $CFLAGS $CPPFLAGS -l[$1] $LDFLAGS $LIBS" 1>&5;
  2666     ${CC-cc} -o dummy${ac_exeext} dummy.c $CFLAGS $CPPFLAGS -l[$1] $LDFLAGS $LIBS 2>&5;
  2667     _res=$? ;
  2668     rm -f dummy.c dummy${ac_exeext} ;
  2669     if test "$_res" = "0"; then
  2670         AC_MSG_RESULT([yes])
  2671         [$2]
  2672     else
  2673         AC_MSG_RESULT([no])
  2674         [$3]
  2675     fi
  2676 ])
  2678 case "$target_os" in
  2679 darwin*)
  2680     _HAVE_PTHREADS=1
  2681     ;;
  2682 *)
  2683     MOZ_CHECK_PTHREADS(pthreads,
  2684         _HAVE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthreads",
  2685         MOZ_CHECK_PTHREADS(pthread,
  2686             _HAVE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthread",
  2687             MOZ_CHECK_PTHREADS(c_r,
  2688                 _HAVE_PTHREADS=1 _PTHREAD_LDFLAGS="-lc_r",
  2689                 MOZ_CHECK_PTHREADS(c,
  2690                     _HAVE_PTHREADS=1
  2695     ;;
  2696 esac
  2698 AC_ARG_WITH(pthreads,
  2699     [  --with-pthreads         Use system pthreads library as thread subsystem],
  2700     [ if test "$withval" = "yes"; then
  2701 	    if test -n "$_HAVE_PTHREADS"; then
  2702 		    USE_PTHREADS=1 
  2703 		    USE_USER_PTHREADS=
  2704 		    USE_NSPR_THREADS=
  2705 	    else
  2706 		    AC_MSG_ERROR([ --with-pthreads specified for a system without pthread support ]);
  2707 	    fi
  2708 	  else
  2709 	    USE_PTHREADS=
  2710 	    _PTHREAD_LDFLAGS=
  2711 	  fi],
  2712 	[ if test -n "$_HAVE_PTHREADS" && test -z "$USE_USER_PTHREADS" && test -z "$USE_NSPR_THREADS"; then
  2713 	    USE_PTHREADS=1
  2714 	    USE_USER_PTHREADS=
  2715 	    USE_NSPR_THREADS=
  2716 	  fi])
  2718 AC_ARG_ENABLE(user-pthreads,
  2719     [  --enable-user-pthreads  Build using userland pthreads],
  2720     [ if test "$enableval" = "yes"; then
  2721         if test -n "$_HAVE_PTHREADS"; then
  2722 		    USE_PTHREADS=
  2723 		    USE_USER_PTHREADS=1
  2724 		    USE_NSPR_THREADS=
  2725 	    else
  2726 		    AC_MSG_ERROR([ --enable-user-pthreads specified for a system without pthread support ]);
  2727 	    fi
  2728 	  fi])
  2730 AC_ARG_ENABLE(nspr-threads,
  2731     [  --enable-nspr-threads   Build using classic nspr threads],
  2732     [ if test "$enableval" = "yes"; then
  2733 	    USE_PTHREADS=
  2734 	    USE_USER_PTHREADS=
  2735 	    USE_NSPR_THREADS=1
  2736 	  fi])
  2738 case "$target" in
  2739 *-beos*)
  2740     AC_ARG_WITH(bthreads,
  2741     [  --with-bthreads         Use system bthreads library as thread subsystem
  2742                           (BeOS only)],
  2743     [	if test "$withval" = "yes"; then
  2744     	    USE_BTHREADS=1
  2745 	        USE_USER_PTHREADS=
  2746 	        USE_PTHREADS=
  2747 	    fi])
  2748     ;;
  2749 esac
  2751 fi # SKIP_LIBRARY_CHECKS
  2753 AC_ARG_ENABLE(ipv6,
  2754     [  --enable-ipv6           Compile ipv6 support],
  2755     [ if test "$enableval" = "yes"; then
  2756 	    USE_IPV6=1
  2757       else
  2758 	    USE_IPV6=
  2759       fi])
  2761 if test -n "$USE_PTHREADS"; then
  2762    dnl See if -pthread is supported.
  2763    rm -f conftest*
  2764    ac_cv_have_dash_pthread=no
  2765    AC_MSG_CHECKING(whether ${CC-cc} accepts -pthread)
  2766    echo 'int main() { return 0; }' | cat > conftest.c
  2767    ${CC-cc} -pthread -o conftest conftest.c > conftest.out 2>&1
  2768    if test $? -eq 0; then
  2769 	if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthread`" && test -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
  2770 	    ac_cv_have_dash_pthread=yes
  2771 		case "$target_os" in
  2772 	    freebsd*)
  2773 # Freebsd doesn't use -pthread for compiles, it uses them for linking
  2774             ;;
  2775 	    *)
  2776             CFLAGS="$CFLAGS -pthread"
  2777             CXXFLAGS="$CXXFLAGS -pthread"
  2778             ;;
  2779         esac
  2780 	fi
  2781     fi
  2782     rm -f conftest*
  2783     AC_MSG_RESULT($ac_cv_have_dash_pthread)
  2785 	dnl
  2786 	dnl See if -pthreads is supported.
  2787 	dnl
  2788     ac_cv_have_dash_pthreads=no
  2789     if test "$ac_cv_have_dash_pthread" = "no"; then
  2790 	    AC_MSG_CHECKING(whether ${CC-cc} accepts -pthreads)
  2791     	echo 'int main() { return 0; }' | cat > conftest.c
  2792 	    ${CC-cc} -pthreads -o conftest conftest.c > conftest.out 2>&1
  2793     	if test $? -eq 0; then
  2794 	    	if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthreads`" && test -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
  2795 			    ac_cv_have_dash_pthreads=yes
  2796 			    CFLAGS="$CFLAGS -pthreads"
  2797 			    CXXFLAGS="$CXXFLAGS -pthreads"
  2798 		    fi
  2799 	    fi
  2800 	    rm -f conftest*
  2801     	AC_MSG_RESULT($ac_cv_have_dash_pthreads)
  2802     fi
  2804     case "$target" in
  2805     *-solaris*)
  2806         if test "$ac_cv_have_dash_pthreads" = "yes"; then
  2807             _PTHREAD_LDFLAGS=
  2808         fi
  2809 	    ;;
  2810     *-freebsd*)
  2811 	    AC_DEFINE(_REENTRANT)
  2812 	    AC_DEFINE(_THREAD_SAFE)
  2813 	    dnl -pthread links in -lc_r, so don't specify it explicitly.
  2814 	    if test "$ac_cv_have_dash_pthread" = "yes"; then
  2815 	        _PTHREAD_LDFLAGS="-pthread"
  2816 	    else
  2817 	        _PTHREAD_LDFLAGS="-lc_r"
  2818 	    fi
  2819 	    ;;
  2820     *-netbsd*)
  2821 	    if test "$ac_cv_have_dash_pthread" = "yes"; then
  2822 	        _PTHREAD_LDFLAGS="-pthread"
  2823 	    fi
  2824 	    ;;
  2825     *-bsdi*)
  2826 	    AC_DEFINE(_THREAD_SAFE)
  2827 	    dnl -pthread links in -lc_r, so don't specify it explicitly.
  2828 	    if test "$ac_cv_have_dash_pthread" = "yes"; then
  2829 	        _PTHREAD_LDFLAGS=
  2830 	    fi
  2831 	    ;;
  2832     *-openbsd*)
  2833         if test "$ac_cv_have_dash_pthread" = "yes"; then
  2834             _PTHREAD_LDFLAGS=-pthread
  2835         fi
  2836         ;;
  2837     *-linux*|*-gnu*|*-k*bsd*-gnu)
  2838         AC_DEFINE(_REENTRANT)
  2839         ;;
  2840     esac
  2842 else 
  2843     if test -n "$USE_USER_PTHREADS"; then
  2844 	    USE_PTHREADS=
  2845 	    USE_NSPR_THREADS=
  2846     else
  2847         _PTHREAD_LDFLAGS=
  2848     fi
  2849 fi
  2850 dnl Special thread exceptions
  2852 case "$target" in
  2853 *-aix*)
  2854     if test -n "$USE_NSPR_THREADS"; then
  2855         AC_DEFINE(_PR_LOCAL_THREADS_ONLY)
  2856     fi
  2857     case "$target_os" in
  2858     aix4.1*)
  2859         if test -z "$USE_PTHREADS"; then
  2860             AC_DEFINE(AIX_RENAME_SELECT)
  2861         fi
  2862         ;;
  2863     aix4.2*)
  2864         if test -z "$USE_NSPR_THREADS"; then
  2865             AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
  2866         fi
  2867         ;;
  2868     aix4.3*)
  2869         if test -z "$USE_NSPR_THREADS"; then
  2870             AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
  2871         fi
  2872         if test -n "$USE_PTHREADS"; then
  2873             AC_DEFINE(_PR_HAVE_THREADSAFE_GETHOST)
  2874         fi
  2875         ;;
  2876     *)
  2877         if test -z "$USE_NSPR_THREADS"; then
  2878             AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
  2879         fi
  2880         if test -n "$USE_PTHREADS"; then
  2881             AC_DEFINE(_PR_HAVE_THREADSAFE_GETHOST)
  2882         fi
  2883         ;;
  2884     esac
  2885     ;;
  2886 *-bsdi*)
  2887     if test -n "$USE_PTHREADS"; then
  2888         AC_DEFINE(_PR_NEED_PTHREAD_INIT)
  2889     fi
  2890     ;;
  2891 *-freebsd*)
  2892     if test -n "$USE_NSPR_THREADS"; then
  2893         AC_DEFINE(_PR_LOCAL_THREADS_ONLY)
  2894     fi
  2895     ;;
  2896 *-hpux*)
  2897     if test -n "$USE_NSPR_THREADS"; then
  2898         AC_DEFINE(_PR_LOCAL_THREADS_ONLY)
  2899     fi 
  2900     if test "$USE_PTHREADS"; then
  2901         if echo "$OS_RELEASE" | egrep '^(B.10.10|B.10.20)' >/dev/null; then
  2902             AC_DEFINE(_REENTRANT)
  2903             AC_DEFINE(_PR_DCETHREADS)
  2904         else
  2905             AC_DEFINE_UNQUOTED(_POSIX_C_SOURCE,199506L)
  2906             AC_DEFINE(_PR_HAVE_THREADSAFE_GETHOST)
  2907         fi
  2908     fi
  2909     if test "$USE_USER_PTHREADS"; then
  2910         AC_DEFINE_UNQUOTED(_POSIX_C_SOURCE,199506L)
  2911     fi
  2912     ;;
  2913 *-irix*)
  2914     if test "${target_os}" = "irix6.5"; then
  2915         if test -n "$USE_PTHREADS"; then
  2916             AC_DEFINE(_PR_HAVE_GETHOST_R)
  2917             AC_DEFINE(_PR_HAVE_GETHOST_R_POINTER)
  2918         fi
  2919     fi
  2920     ;;
  2921 *-linux*|*-gnu*|*-k*bsd*-gnu)
  2922     if test -n "$USE_NSPR_THREADS"; then
  2923         AC_DEFINE(_PR_LOCAL_THREADS_ONLY)
  2924     fi
  2925     ;;
  2926 *-mingw*|*-msys*|*-cygwin*|*-mks*|*-os2*|*-beos*)
  2927     dnl win32, os2 & beos cannot use pthreads
  2928     USE_PTHREADS=
  2929     _PTHREAD_LDFLAGS=
  2930     USE_USER_PTHREADS=
  2931     ;;
  2932 *-netbsd*|*-openbsd*)
  2933     if test -n "$USE_NSPR_THREADS"; then
  2934         AC_DEFINE(_PR_LOCAL_THREADS_ONLY)
  2935     fi
  2936     ;;
  2937 *-osf*)
  2938     if test -n "$USE_NSPR_THREADS"; then
  2939         AC_DEFINE(_PR_LOCAL_THREADS_ONLY)
  2940     fi
  2941     if test -n "$USE_PTHREADS"; then
  2942         if echo $OS_RELEASE | egrep -c '(V2.0|V3.2)' 2>/dev/null; then
  2944         else
  2945             AC_DEFINE(_PR_HAVE_THREADSAFE_GETHOST)
  2946         fi
  2947     fi
  2948     ;;
  2949 *-solaris*)
  2950     if test -n "$USE_NSPR_THREADS"; then
  2951         AC_DEFINE(_PR_LOCAL_THREADS_ONLY)
  2952     fi
  2953     if test -n "$USE_PTHREADS"; then
  2954         AC_DEFINE(_REENTRANT)
  2955         AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
  2956         if test "$OS_TEST" = "i86pc"; then
  2957             if test -n "$USE_64"; then
  2958                PR_MD_ASFILES=os_SunOS_x86_64.s
  2959             else
  2960                PR_MD_ASFILES=os_SunOS_x86.s
  2961             fi
  2962         else
  2963             if test -n "$USE_64"; then
  2964                 PR_MD_ASFILES=os_SunOS_sparcv9.s
  2965             fi
  2966         fi
  2967     fi
  2968     ;;
  2969 *-nto*)
  2970     if test -n "$USE_PTHREADS"; then
  2971         AC_DEFINE(_PR_HAVE_GETHOST_R)
  2972         AC_DEFINE(_PR_HAVE_GETHOST_R_POINTER)
  2973     fi
  2974     ;;
  2975 esac
  2977 OS_LIBS="$_PTHREAD_LDFLAGS $OS_LIBS"
  2979 dnl If the user passed in arg to --enable-optimize or --enable-debug,
  2980 dnl make sure that we use it.
  2981 if test -n "$_SAVE_OPTIMIZE_FLAGS"; then
  2982     _OPTIMIZE_FLAGS="$_SAVE_OPTIMIZE_FLAGS"
  2983 fi
  2985 if test -n "$_SAVE_DEBUG_FLAGS"; then
  2986     _DEBUG_FLAGS="$_SAVE_DEBUG_FLAGS"
  2987 fi
  2989 if test -n "$MOZ_OPTIMIZE"; then
  2990     CFLAGS="$CFLAGS $_OPTIMIZE_FLAGS"
  2991     CXXFLAGS="$CXXFLAGS $_OPTIMIZE_FLAGS"
  2992 fi
  2994 if test -n "$MOZ_DEBUG_SYMBOLS"; then
  2995     CFLAGS="$CFLAGS $_DEBUG_FLAGS"
  2996     CXXFLAGS="$CXXFLAGS $_DEBUG_FLAGS"
  2997 fi
  2999 if test -n "$MOZ_OPTIMIZE"; then
  3000     OBJDIR_TAG=_OPT
  3001 else
  3002     OBJDIR_TAG=_DBG
  3003 fi
  3005 if test -n "$USE_64"; then
  3006     COMPILER_TAG=_64
  3007 fi
  3009 RELEASE_OBJDIR_NAME="${OS_CONFIG}${CPU_ARCH_TAG}${COMPILER_TAG}${IMPL_STRATEGY}${OBJDIR_TAG}.${OBJDIR_SUFFIX}"
  3011 dnl ========================================================
  3012 dnl Use cygwin wrapper for win32 builds, except MSYS/MinGW
  3013 dnl ========================================================
  3014 case "$target_os" in
  3015 cygwin*|mks*)
  3016     CC="\$(CYGWIN_WRAPPER) $CC"
  3017     CXX="\$(CYGWIN_WRAPPER) $CXX"
  3018     RC="\$(CYGWIN_WRAPPER) $RC"
  3019     ;;
  3020 esac
  3022 dnl ========================================================
  3023 dnl = Use malloc wrapper lib
  3024 dnl ========================================================
  3025 AC_ARG_ENABLE(wrap-malloc,
  3026 [  --enable-wrap-malloc    Wrap malloc calls (gnu linker only)],
  3027 [     if test "$enableval" = "yes"; then
  3028 	    _WRAP_MALLOC=1
  3029       fi ])
  3031 if test -n "$_WRAP_MALLOC"; then
  3032     if test -n "$GNU_CC"; then
  3033         WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=malloc,--wrap=calloc,--wrap=valloc,--wrap=free,--wrap=realloc,--wrap=memalign"
  3034         WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=__builtin_new,--wrap=__builtin_vec_new,--wrap=__builtin_delete,--wrap=__builtin_vec_delete"
  3035         WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=strdup,--wrap=strndup"
  3036         WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=posix_memalign,--wrap=malloc_usable_size"
  3037     else
  3038         AC_MSG_ERROR([--enable-wrap-malloc is not supported for non-GNU toolchains])
  3039     fi
  3040 fi
  3042 dnl ========================================================
  3043 dnl = Location of malloc wrapper lib
  3044 dnl ========================================================
  3045 AC_ARG_WITH(wrap-malloc,
  3046 [  --with-wrap-malloc=SHAREDLIB  Location of malloc wrapper library],
  3047     WRAP_LDFLAGS="${WRAP_LDFLAGS} $withval")
  3049 dnl ========================================================
  3050 dnl Substitution of found variables.
  3051 dnl ========================================================
  3052 AC_SUBST(SHELL_OVERRIDE)
  3054 AC_SUBST(MOZILLA_CLIENT)
  3055 AC_SUBST(CC)
  3056 AC_SUBST(CXX)
  3057 AC_SUBST(CFLAGS)
  3058 AC_SUBST(CXXFLAGS)
  3059 AC_SUBST(CPPFLAGS)
  3060 AC_SUBST(HOST_CC)
  3061 AC_SUBST(HOST_CFLAGS)
  3062 AC_SUBST(LDFLAGS)
  3063 AC_SUBST(HOST_LDFLAGS)
  3064 AC_SUBST(GNU_CC)
  3065 AC_SUBST(GCC_USE_GNU_LD)
  3066 AC_SUBST(MSC_VER)
  3067 AC_SUBST(CROSS_COMPILE)
  3069 AC_SUBST(MOZ_OPTIMIZE)
  3070 AC_SUBST(MOZ_DEBUG)
  3071 AC_SUBST(MOZ_DEBUG_SYMBOLS)
  3073 AC_SUBST(USE_CPLUS)
  3074 AC_SUBST(USE_IPV6)
  3075 AC_SUBST(USE_N32)
  3076 AC_SUBST(USE_X32)
  3077 AC_SUBST(USE_64)
  3078 AC_SUBST(OBJECT_MODE)
  3079 AC_SUBST(ENABLE_STRIP)
  3081 AC_SUBST(USE_PTHREADS)
  3082 AC_SUBST(USE_BTHREADS)
  3083 AC_SUBST(USE_USER_PTHREADS)
  3084 AC_SUBST(USE_NSPR_THREADS)
  3086 AC_SUBST(LIBNSPR)
  3087 AC_SUBST(LIBPLC)
  3089 AC_SUBST(MOD_MAJOR_VERSION)
  3090 AC_SUBST(MOD_MINOR_VERSION)
  3091 AC_SUBST(MOD_PATCH_VERSION)
  3092 AC_SUBST(NSPR_MODNAME)
  3093 AC_SUBST(MDCPUCFG_H)
  3094 AC_SUBST(PR_MD_CSRCS)
  3095 AC_SUBST(PR_MD_ASFILES)
  3096 AC_SUBST(PR_MD_ARCH_DIR)
  3097 AC_SUBST(CPU_ARCH)
  3099 AC_SUBST(OBJ_SUFFIX)
  3100 AC_SUBST(LIB_SUFFIX)
  3101 AC_SUBST(DLL_SUFFIX)
  3102 AC_SUBST(ASM_SUFFIX)
  3103 AC_SUBST(WRAP_LDFLAGS)
  3104 AC_SUBST(MKSHLIB)
  3105 AC_SUBST(DSO_CFLAGS)
  3106 AC_SUBST(DSO_LDOPTS)
  3108 AC_SUBST(OS_TARGET)
  3109 AC_SUBST(OS_ARCH)
  3110 AC_SUBST(OS_RELEASE)
  3111 AC_SUBST(OS_TEST)
  3112 AC_SUBST(MACOSX_DEPLOYMENT_TARGET)
  3114 AC_SUBST(DEFINES)
  3115 AC_SUBST(DEFS)
  3116 AC_SUBST(AR)
  3117 AC_SUBST(AR_FLAGS)
  3118 AC_SUBST(AS)
  3119 AC_SUBST(ASFLAGS)
  3120 AC_SUBST(LD)
  3121 AC_SUBST(RANLIB)
  3122 AC_SUBST(PERL)
  3123 AC_SUBST(STRIP)
  3124 AC_SUBST(FILTER)
  3125 AC_SUBST(IMPLIB)
  3127 AC_SUBST(PROFILE_GEN_CFLAGS)
  3128 AC_SUBST(PROFILE_GEN_LDFLAGS)
  3129 AC_SUBST(PROFILE_USE_CFLAGS)
  3130 AC_SUBST(PROFILE_USE_LDFLAGS)
  3132 AC_SUBST(OS_LIBS)
  3133 AC_SUBST(RESOLVE_LINK_SYMBOLS)
  3134 AC_SUBST(AIX_LINK_OPTS)
  3135 AC_SUBST(NOSUCHFILE)
  3136 AC_SUBST(MOZ_OBJFORMAT)
  3137 AC_SUBST(ULTRASPARC_LIBRARY)
  3139 AC_SUBST(OBJDIR)
  3140 AC_SUBST(OBJDIR_NAME)
  3141 AC_SUBST(RELEASE_OBJDIR_NAME)
  3142 AC_SUBST(NSINSTALL)
  3143 AC_SUBST(OPTIMIZER)
  3144 AC_SUBST(RC)
  3145 AC_SUBST(RCFLAGS)
  3146 AC_SUBST(DLLFLAGS)
  3147 AC_SUBST(EXEFLAGS)
  3148 AC_SUBST(OS_DLLFLAGS)
  3149 AC_SUBST(CYGWIN_WRAPPER)
  3150 AC_SUBST(VISIBILITY_FLAGS)
  3151 AC_SUBST(WRAP_SYSTEM_INCLUDES)
  3152 AC_SUBST(MACOS_SDK_DIR)
  3153 AC_SUBST(SYMBIAN_SDK_DIR)
  3154 AC_SUBST(NEXT_ROOT)
  3155 AC_SUBST(MT)
  3157 dnl ========================================================
  3158 dnl Generate output files.
  3159 dnl ========================================================
  3160 MAKEFILES="
  3161     Makefile
  3162     config/Makefile
  3163     config/autoconf.mk
  3164     config/nsprincl.mk
  3165     config/nsprincl.sh
  3166     config/nspr-config
  3167     config/nspr.pc
  3168     lib/Makefile
  3169     lib/ds/Makefile
  3170     lib/libc/Makefile
  3171     lib/libc/include/Makefile
  3172     lib/libc/src/Makefile
  3173     lib/tests/Makefile
  3174     pkg/Makefile
  3175     pr/Makefile
  3176     pr/include/Makefile
  3177     pr/include/md/Makefile
  3178     pr/include/obsolete/Makefile
  3179     pr/include/private/Makefile
  3180     pr/src/Makefile
  3181     pr/src/io/Makefile
  3182     pr/src/linking/Makefile
  3183     pr/src/malloc/Makefile
  3184     pr/src/md/Makefile
  3185     pr/src/md/${PR_MD_ARCH_DIR}/Makefile
  3186     pr/src/memory/Makefile
  3187     pr/src/misc/Makefile
  3188     pr/src/threads/Makefile
  3189     pr/tests/Makefile
  3190     pr/tests/dll/Makefile
  3193 if test "$OS_TARGET" = "Linux"; then
  3194     MAKEFILES="$MAKEFILES
  3195         pkg/linux/Makefile
  3197 elif test "$OS_TARGET" = "SunOS"; then
  3198     MAKEFILES="$MAKEFILES
  3199         pkg/solaris/Makefile
  3200         pkg/solaris/SUNWpr/Makefile
  3201         pkg/solaris/SUNWprd/Makefile
  3203 fi
  3205 if test -z "$USE_PTHREADS" && test -z "$USE_BTHREADS"; then
  3206     MAKEFILES="$MAKEFILES
  3207         pr/src/threads/combined/Makefile
  3209 elif test -n "$USE_PTHREADS"; then
  3210     MAKEFILES="$MAKEFILES
  3211         pr/src/pthreads/Makefile
  3213 elif test -n "$USE_BTHREADS"; then
  3214     MAKEFILES="$MAKEFILES
  3215         pr/src/bthreads/Makefile
  3217 fi
  3219 if test -n "$USE_CPLUS"; then
  3220     MAKEFILES="$MAKEFILES
  3221         pr/src/cplus/Makefile
  3222         pr/src/cplus/tests/Makefile
  3224 fi
  3226 echo $MAKEFILES > unallmakefiles
  3228 AC_CONFIG_FILES([$MAKEFILES])
  3229 AC_CONFIG_COMMANDS([default], [chmod +x config/nspr-config])
  3230 AC_OUTPUT

mercurial