c-sdk/configure.in
author Landry Breuil <landry@openbsd.org>
Thu, 24 Jan 2013 14:39:48 +0100
changeset 37 2b72c62f545044b70c61e4c59a5285010154d591
parent 35 5b05e409d5120fdc5018772250d45ebd41c644ee
child 39 badd67031f9ece08c36b9d9cd17de33833038618
permissions -rw-r--r--
Bug 720373 followup : regen configure with autoconf after configure.in change. rs=standard8

dnl -*- Mode: Autoconf; tab-width: 4; indent-tabs-mode: nil; -*-
dnl 
dnl ***** BEGIN LICENSE BLOCK *****
dnl Version: MPL 1.1/GPL 2.0/LGPL 2.1
dnl 
dnl The contents of this file are subject to the Mozilla Public License Version 
dnl 1.1 (the "License"); you may not use this file except in compliance with 
dnl the License. You may obtain a copy of the License at 
dnl http://www.mozilla.org/MPL/
dnl 
dnl Software distributed under the License is distributed on an "AS IS" basis,
dnl WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
dnl for the specific language governing rights and limitations under the
dnl License.
dnl 
dnl The Original Code is the Netscape Portable Runtime (NSPR).
dnl 
dnl The Initial Developer of the Original Code is
dnl Netscape Communications Corporation.
dnl Portions created by the Initial Developer are Copyright (C) 1998-2000
dnl the Initial Developer. All Rights Reserved.
dnl 
dnl Contributor(s):
dnl   Christopher Seawood <cls@seawood.org>
dnl   Dan Mosedale <dmose@netscape.com>
dnl   Howard Chu <hyc@symas.com>
dnl 
dnl Alternatively, the contents of this file may be used under the terms of
dnl either of the GNU General Public License Version 2 or later (the "GPL"),
dnl or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
dnl in which case the provisions of the GPL or the LGPL are applicable instead
dnl of those above. If you wish to allow use of your version of this file only
dnl under the terms of either the GPL or the LGPL, and not to allow others to
dnl use your version of this file under the terms of the MPL, indicate your
dnl decision by deleting the provisions above and replace them with the notice
dnl and other provisions required by the GPL or the LGPL. If you do not delete
dnl the provisions above, a recipient may use your version of this file under
dnl the terms of any one of the MPL, the GPL or the LGPL.
dnl 
dnl ***** END LICENSE BLOCK ***** 

AC_PREREQ(2.12)
AC_INIT(ldap/include/ldap.h)

AC_CONFIG_AUX_DIR(${srcdir}/config/autoconf)
AC_CANONICAL_SYSTEM

dnl ========================================================
dnl = Defaults
dnl ========================================================
NSPR_VERSION=4
_HAVE_PTHREADS=
USE_PTHREADS=
USE_USER_PTHREADS=
USE_NSPR_THREADS=
USE_N32=
USE_64=
USE_CPLUS=
USE_IPV6=
USE_MDUPDATE=
_OPTIMIZE_FLAGS=-O
_DEBUG_FLAGS=-g
MOZ_DEBUG=
MOZ_OPTIMIZE=1
MFLAGS=
OBJDIR=.
OBJDIR_NAME=.
NSINSTALL='$(MOD_DEPTH)/config/$(OBJDIR_NAME)/nsinstall'
NOSUCHFILE=/no-such-file
MOZ_OS2_HIGH_MEMORY=1

dnl Link in libraries necessary to resolve all symbols for shared libs
RESOLVE_LINK_SYMBOLS=

dnl ========================================================
dnl =
dnl = Dont change the following lines.  Doing so breaks:
dnl =
dnl = CFLAGS="-foo" ./configure
dnl =
dnl ========================================================
CFLAGS="${CFLAGS=}"
CXXFLAGS="${CXXFLAGS=}"
LDFLAGS="${LDFLAGS=}"
DLLFLAGS="${DLLFLAGS=}"
HOST_CFLAGS="${HOST_CFLAGS=}"
HOST_LDFLAGS="${HOST_LDFLAGS=}"

case "$target" in
*-cygwin*|*-mingw*|*-msvc*|*-mks*)
    # Check to see if we are really running in a msvc environemnt
    _WIN32_MSVC=
    AC_CHECK_PROGS(CC, cl)
    if test "$CC" = "cl"; then
        echo 'main() { return 0; }' > dummy.c
        ${CC} -o dummy dummy.c >/dev/null 2>&1
        if test $? = 0; then
            _WIN32_MSVC=1
            CXX=$CC
        else
            AC_MSG_WARN([$(CC) test failed.  Using normal feature tests])
        fi
        rm -f dummy dummy.o dummy.obj dummy.exe dummy.c
    fi
    ;;
esac

if test -n "$_WIN32_MSVC"; then
    SKIP_PATH_CHECKS=1
    SKIP_COMPILER_CHECKS=1
    SKIP_LIBRARY_CHECKS=1
fi

dnl ========================================================
dnl =
dnl = Check options that may affect the compiler
dnl =
dnl ========================================================
dist_prefix='${MOD_DEPTH}/../../dist'
dist_bindir='${dist_prefix}/bin'
dist_libdir='${dist_prefix}/lib'

AC_ARG_WITH(dist-prefix,
    [  --with-dist-prefix=DIST_PREFIX
                          place build files in DIST_PREFIX [dist]],
    dist_prefix=$withval)

AC_ARG_WITH(dist-bindir,
    [  --with-dist-bindir=DIR  build execuatables in DIR [DIST_PREFIX/bin]],
    dist_bindir=$withval)

AC_ARG_WITH(dist-libdir,
    [  --with-dist-libdir=DIR  build library files in DIR [DIST_PREFIX/lib]],
    dist_libdir=$withval)

AC_SUBST(dist_prefix)
AC_SUBST(dist_bindir)
AC_SUBST(dist_libdir)

dnl Check if LDAP is being compiled for Mozilla
dnl Let --with-arg override environment setting
dnl
AC_ARG_WITH(mozilla,
    [  --with-mozilla          Compile LDAP with Mozilla support],
    [   if test "$withval" = "yes"; then
            AC_DEFINE(MOZILLA_CLIENT)
            MOZILLA_CLIENT=1
	    else
	        MOZILLA_CLIENT=
	    fi],
    [	if test -n "$MOZILLA_CLIENT"; then
	        AC_DEFINE(MOZILLA_CLIENT)
	    fi])

AC_ARG_ENABLE(optimize,
    [  --enable-optimize(=val) Enable code optimizations (val, ie. -O2) ],
    [ if test "$enableval" != "no"; then
        MOZ_OPTIMIZE=1
        if test -n "$enableval" && test "$enableval" != "yes"; then
    	    _OPTIMIZE_FLAGS=`echo $enableval | sed -e 's|\\\ | |g'`
            _SAVE_OPTIMIZE_FLAGS=$_OPTIMIZE_FLAGS
        fi
      else
        MOZ_OPTIMIZE=
    fi ])

AC_ARG_ENABLE(debug,
    [  --enable-debug(=val)    Enable debugging (debug flags val)],
    [ if test "$enableval" != "no"; then
            MOZ_DEBUG=1
            if test -n "$enableval" && test "$enableval" != "yes"; then
    	        _DEBUG_FLAGS=`echo $enableval | sed -e 's|\\\ | |g'`
                _SAVE_DEBUG_FLAGS=$_DEBUG_FLAGS
            fi
      else
            MOZ_DEBUG=
    fi])

AC_ARG_ENABLE(win32-target,
    [  --enable-win32-target=\$t
                          Specify win32 flavor. (WIN95 or WINNT)],
    OS_TARGET=`echo $enableval | tr a-z A-Z`,
    OS_TARGET=)

AC_ARG_ENABLE(debug-rtl,
    [  --enable-debug-rtl      Use the MSVC debug runtime library],
    [ if test "$enableval" = "yes"; then
	    USE_DEBUG_RTL=1
      fi ])

AC_ARG_ENABLE(n32,
    [  --enable-n32            Enable n32 ABI support (IRIX only)],
    [ if test "$enableval" = "yes"; then
	USE_N32=1
      else if test "$enableval" = "no"; then
	USE_N32=
      fi
    fi ])

AC_ARG_ENABLE(64bit,
    [  --enable-64bit          Enable 64-bit support (on certain platforms)],
    [ if test "$enableval" = "yes"; then
	    USE_64=1 ; export USE_64
      fi ],
    [])

AC_ARG_ENABLE(mdupdate,
    [  --enable-mdupdate       Enable use of certain compilers' mdupdate feature],
    [ if test "$enableval" = "yes"; then
	    USE_MDUPDATE=1
      fi ])

dnl ========================================================
dnl = build the optional command-line utilities such as
dnl = ldapsearch and ldapmodify.
dnl ========================================================
AC_ARG_ENABLE(clu,
   [  --enable-clu            Enable building the command-line utilities],
   [ if test "$enableval" = "yes"; then
           BUILDCLU=1
           AC_SUBST(BUILDCLU)
     fi ],
   []) 

dnl ========================================================
dnl = svrcore gives the command line tools secure PIN management
dnl = for client cert based authentication
dnl ========================================================
dnl ========================================================
dnl = Use the SVRCORE copy in the system (assuming it exists) 
dnl = rather than the one in the source tree (mozilla/security)
dnl ========================================================
AC_ARG_WITH(system-svrcore,
    [  --with-system-svrcore   Use system installed SVRCORE],
    [   if test "$withval" = "yes"; then
            _SYSTEM_SVRCORE=1
            HAVE_SVRCORE=1
            SVRCORE_LIBS=-lsvrcore
            AC_SUBST(SVRCORE_LIBS)
            AC_SUBST(HAVE_SVRCORE)
dnl svrcore implies both nspr and nss
            USE_NSS=1
            no_nspr=no
	    else
            _SYSTEM_SVRCORE=
	    fi], _SYSTEM_SVRCORE= )

dnl _SYSTEM_SVRCORE means /usr/lib and /usr/include so no need to add additional
dnl include or lib paths
if test -z "$_SYSTEM_SVRCORE" ; then
   dnl first, see if user has specified explicit SVRCORE include and lib paths
   AM_PATH_GIVEN_SVRCORE()

   dnl next, see if user explicitly said to use system svrcore
   if test -n "$HAVE_SVRCORE" ; then
dnl svrcore implies both nspr and nss
       USE_NSS=1
       HAVE_SVRCORE=1
       AC_SUBST(HAVE_SVRCORE)
       no_nspr=no
       if test -z "$SVRCORE_CFLAGS" -o -z "$SVRCORE_LIBS" ; then
           if test -n "$_SYSTEM_SVRCORE"; then
               AM_PATH_SVRCORE(4.0.1, [MOZ_NATIVE_SVRCORE=1], [MOZ_NATIVE_SVRCORE=])
           else
       	       dnl see if we are being built in the same build tree as svrcore
               AM_PATH_INTREE_SVRCORE(../../dist)
               dnl failing that, see if we can find svrcore-config or pkg-config svrcore
               if test -z "$SVRCORE_CFLAGS" -o -z "$SVRCORE_LIBS"; then
                   AM_PATH_SVRCORE(4.0.1, [MOZ_NATIVE_SVRCORE=1], [MOZ_NATIVE_SVRCORE=])
               fi
           fi
       fi
   fi
fi

if test -n "$HAVE_SVRCORE" -a -z "$_SYSTEM_SVRCORE" ; then
   if test -z "$SVRCORE_CFLAGS" -o -z "$SVRCORE_LIBS"; then
      AC_MSG_ERROR([--with-svrcore specified, but no svrcore could be found])
   fi
fi

dnl ========================================================
dnl = Use the NSS copy in the system (assuming it exists) 
dnl = rather than the one in the source tree (mozilla/security)
dnl ========================================================
AC_ARG_WITH(system-nss,
    [  --with-system-nss   Use system installed NSS],
    [   if test "$withval" = "yes"; then
            _SYSTEM_NSS=1
            USE_NSS=1
dnl nss requires nspr
            no_nspr=no
	    elif test "$withval" = "no" ; then
            _SYSTEM_NSS=no
	    fi], _SYSTEM_NSS= )

if test "$_WIN32_MSVC"; then
    _SYSTEM_NSS=
fi

dnl first, see if user has specified explicit NSPR include and lib paths,
dnl of if the user has explicitly disabled the use of nss
if test -z "$_SYSTEM_NSS" -o "$_SYSTEM_NSS" = "no" ; then
   AM_PATH_GIVEN_NSS()
fi

dnl next, see if user explicitly said to use system nss
if test -n "$USE_NSS" -a -z "$NSS_CFLAGS" -a -z "$NSS_LIBS" ; then
dnl nss requires nspr
   no_nspr=no
   if test -z "$_SYSTEM_NSS" -o "$_SYSTEM_NSS" = "no" ; then
dnl see if we are being built in the same build tree as nss
      AM_PATH_INTREE_NSS(../../dist)
   fi
dnl failing that, see if we can find nss-config or pkg-config nss
   if test -z "$NSS_CFLAGS" -a "$_SYSTEM_NSS" != "no" ; then
      AM_PATH_NSS(3.9.0, [MOZ_NATIVE_NSS=1], [MOZ_NATIVE_NSS=])
   fi
fi

dnl bomb out if nss not found
if test -n "$USE_NSS" -a -z "$NSS_CFLAGS" -a -z "$NSS_LIBS" ; then
   AC_MSG_ERROR(Need to use NSS but no NSS was found)
fi

dnl ========================================================
dnl = Use the NSPR copy in the system (assuming it exists) 
dnl = rather than the one in the source tree (mozilla/nsprpub)
dnl ========================================================
AC_ARG_WITH(system-nspr,
    [  --with-system-nspr   Use system installed NSPR],
    [   if test "$withval" = "yes"; then
            _SYSTEM_NSPR=1
            no_nspr=no
	    elif test "$withval" = "no"; then
            _SYSTEM_NSPR=no
	    fi], _SYSTEM_NSPR= )

if test "$_WIN32_MSVC"; then
    _SYSTEM_NSPR=no
fi

dnl first, see if user has specified explicit NSPR include and lib paths,
dnl of if the user has explicitly disabled the use of nspr
if test -z "$_SYSTEM_NSPR" -o "$_SYSTEM_NSPR" = "no" ; then
   AM_PATH_GIVEN_NSPR()
fi

dnl next, look for in-tree nspr if user did not specify explicit system nspr
if test "$no_nspr" = "no" -a -z "$NSPR_CFLAGS" -a -z "$NSPR_LIBS" ; then
   if test -z "$_SYSTEM_NSPR" -o "$_SYSTEM_NSPR" = "no" ; then
dnl see if we are being built in the same build tree as nspr
      AM_PATH_INTREE_NSPR(../../dist)
   fi
dnl failing that, see if we can find nspr-config or pkg-config nspr
   if test -z "$NSPR_CFLAGS" -a "$_SYSTEM_NSPR" != "no" ; then
      AM_PATH_NSPR(4.0.0, [MOZ_NATIVE_NSPR=1], [MOZ_NATIVE_NSPR=])
   fi
fi

dnl if we are being built as part of the mozilla client, and we could not
dnl find NSPR by any other method, just default to the default values
dnl used by the client build - NOTE that this sets the libpaths and the
dnl library link commands directly, so we don't need to muck with any
dnl cygwin path conversion stuff.  The client build also uses --with-dist-prefix
dnl which sets $(DIST) in the makefiles
if test -z "$NSPR_CFLAGS" -o -z "$NSPR_LIBS" ; then
   if test -n "$MOZILLA_CLIENT" ; then
       NSPR_CFLAGS='-I$(DIST)/include/nspr'
       NSPR_LIBS='-L$(DIST)/lib '"-lplds$NSPR_VERSION -lplc$NSPR_VERSION -lnspr$NSPR_VERSION"
       if test "$_WIN32_MSVC"; then
          NSPR_LIBS='$(DIST)/lib/nspr'$NSPR_VERSION'.lib $(DIST)/lib/plc'$NSPR_VERSION'.lib $(DIST)/lib/plds'$NSPR_VERSION'.lib '
       fi
       LIBS_ALREADY_SET=1
       AC_SUBST(LIBS_ALREADY_SET)
   elif test "$no_nspr" = "no" ; then
       AC_MSG_ERROR(Need to use NSPR but no NSPR was found)
   fi
fi

dnl ========================================================
dnl If using cygwin (or another Windows shell that uses unix
dnl style paths by default - mingw?) and using MSVC, we need
dnl to convert the include and lib paths to the more MSVC
dnl friendly format - it's easier and faster to do it here
dnl than in cygwin-wrapper
dnl ========================================================

dnl add other runtime environments that use unix style paths
dnl *-cygwin*|*-mingw*|*-msvc*|*-mks*)
dnl mozilla-build msys seems not to convert -L to /LIBPATH
dnl it just converts -L to /L and link issues an error
case "$target" in
*-cygwin*) USE_WINDOWS_PATHS=1 ;;
*-mingw*) CONVERT_LIBPATH=1 ;;
esac

if test -n "$_WIN32_MSVC" -a -n "$USE_WINDOWS_PATHS" ; then
    if test -n "$NSPR_CFLAGS" -a -z "$LIBS_ALREADY_SET" ; then
        path=`echo $NSPR_CFLAGS | sed -e 's/^-I//'`
        path=`cygpath -m $path`
        NSPR_CFLAGS="/I$path"
    fi
    if test -n "$NSPR_LIBS" -a -z "$LIBS_ALREADY_SET" ; then
        path=`echo $NSPR_LIBS | sed -e 's/^-L//'`
        path=`cygpath -m $path`
        NSPR_LIBS="/LIBPATH:$path"
    fi

    if test -n "$NSS_CFLAGS" ; then
        path=`echo $NSS_CFLAGS | sed -e 's/^-I//'`
        path=`cygpath -m $path`
        NSS_CFLAGS="/I$path"
    fi

    if test -n "$NSS_LIBS" ; then
        path=`echo $NSS_LIBS | sed -e 's/^-L//'`
        path=`cygpath -m $path`
        NSS_LIBS="/LIBPATH:$path"
    fi

    if test -n "$SVRCORE_CFLAGS" ; then
        path=`echo $SVRCORE_CFLAGS | sed -e 's/^-I//'`
        path=`cygpath -m $path`
        SVRCORE_CFLAGS="/I$path"
    fi

    if test -n "$SVRCORE_LIBS" ; then
        path=`echo $SVRCORE_LIBS | sed -e 's/^-L//'`
        path=`cygpath -m $path`
        SVRCORE_LIBS="/LIBPATH:$path"
    fi
fi

dnl there seems to be no way to pass /libpath:/msys/style/path
dnl to the link command line and have that converted to
dnl /libpath:c:\dos\style\path
dnl i've tried -libpath, /libpath, //libpath
dnl msys does not have the cygpath command - however, pwd -W will
dnl return the current directory in a suitable fornat
if test -n "$_WIN32_MSVC" -a -n "$NSPR_LIBS" -a -n "$CONVERT_LIBPATH" -a -z "$LIBS_ALREADY_SET" ; then
    path=`echo $NSPR_LIBS | sed -e 's/^-L//'`
    path=`cd "$path" ; pwd -W`
    NSPR_LIBS="/LIBPATH:$path"
fi
if test -n "$_WIN32_MSVC" -a -n "$NSS_LIBS" -a -n "$CONVERT_LIBPATH" ; then
    path=`echo $NSS_LIBS | sed -e 's/^-L//'`
    path=`cd "$path" ; pwd -W`
    NSS_LIBS="/LIBPATH:$path"
fi
if test -n "$_WIN32_MSVC" -a -n "$SVRCORE_LIBS" -a -n "$CONVERT_LIBPATH" ; then
    path=`echo $SVRCORE_LIBS | sed -e 's/^-L//'`
    path=`cd "$path" ; pwd -W`
    SVRCORE_LIBS="/LIBPATH:$path"
fi

dnl ========================================================
dnl =
dnl = Set the threading model
dnl =
dnl ========================================================
case "$target" in

*-aix*)
    case "${target_os}" in
    aix3.2*)
        USE_NSPR_THREADS=1
        ;;
    *)
        USE_PTHREADS=1
        ;;
    esac
    ;;

esac

dnl ========================================================
dnl =
dnl = Set the default C compiler
dnl =
dnl ========================================================
if test -z "$CC"; then
    case "$target" in

    *-aix*)
        if test -z "$USE_NSPR_THREADS"; then
            CC=xlC_r
        else
            CC=xlC
        fi
    ;;

    *-hpux*)
        CC=cc
    ;;

    *-irix*)
        CC=cc
    ;;

    *-osf*)
        CC=cc
    ;;

    *-solaris*)
        CC=cc
    ;;

    esac
fi

dnl ========================================================
dnl =
dnl = Set the default C++ compiler
dnl =
dnl ========================================================
if test -z "$CXX"; then
    case "$target" in

    *-aix*)
        if test -z "$USE_NSPR_THREADS"; then
            CXX=xlC_r
        else
            CXX=xlC
        fi
    ;;

    *-hpux*)
        case "${target_os}" in
        hpux10.30)
            CXX=aCC
            ;;
        hpux11.*)
            CXX=aCC
            ;;
        *)
            CXX=CC
            ;;
        esac
    ;;

    *-irix*)
        CXX=CC
    ;;

    *-osf*)
        CXX=cxx
    ;;

    *-solaris*)
        CXX=CC
    ;;

    esac
fi

if test -z "$SKIP_PATH_CHECKS"; then
    AC_PATH_PROG(WHOAMI, $WHOAMI whoami, echo not_whoami)
fi

if test -n "$MOZ_DEBUG"; then
    AC_DEFINE(DEBUG)
    DEFINES="$DEFINES -UNDEBUG"
    case "${target_os}" in
    beos*)
        DEFINES="$DEFINES -DDEBUG_${USER}"
        ;;
    msvc*|mks*|cygwin*|mingw*|os2*)
        DEFINES="$DEFINES -DDEBUG_`echo ${USERNAME} | sed -e 's| |_|g'`"
        ;;
    *) 
        DEFINES="$MOZ_DEBUG_ENABLE_DEFS -DDEBUG_`$WHOAMI`"
        ;;
    esac
    MFLAGS="BUILD_DEBUG=full"
else
    AC_DEFINE(NDEBUG)
    DEFINES="$DEFINES -UDEBUG"
    MFLAGS="BUILD_DEBUG=optimize"
fi

dnl Use mozilla's nsinstall
if test -n "$MOZILLA_CLIENT"; then
   NSINSTALL='$(dist_bindir)/nsinstall'
fi

if test -z "$SKIP_COMPILER_CHECKS"; then
dnl ========================================================
dnl Checks for compilers.
dnl ========================================================
dnl NOTE that according to the latest autoconf 2.5x manual
dnl "Now, configure enters cross-compilation mode if and only if `--host' is passed."
dnl However, the mozilla build system expects us to assume different target and host
dnl means cross compiling.  But, %configure in many linux RPM build systems sets the
dnl following:
dnl ./configure --build=i686-redhat-linux-gnu --host=i686-redhat-linux-gnu --target=i386-redhat-linux-gnu ...
dnl which means that the system is an i686, but we want to produce code which will run on i386 - in
dnl this case, we _do not_ want to cross compile
dnl So, additional logic:
dnl if $host = $build, do not cross compile
dnl otherwise, cross compile if host is given
cross_compiling=no
dnl host must be specified to cross compile
if test -n "$host" ; then
    case $target in
    *-darwin*)
        if test "$host" != "$target" ; then
            cross_compiling=yes
        fi
    ;;
    *)
dnl host == build - do not cross compile
        if test "$host" = "$build" ; then
            cross_compiling=no
dnl host != build or host != target - do cross compile
        elif test "$host" != "$target" -o "$host" != "$build" ; then
            cross_compiling=yes
        fi
    ;;
    esac
fi
if test "$cross_compiling" = "no"; then
    AC_PROG_CXX
    if test "$CXX" = "cl" -a -z "$CC"; then
        CC=$CXX
    else        
        AC_PROG_CC
    fi
    AC_PROG_CPP
    AC_PROG_RANLIB
    AC_PATH_PROGS(AS, as, $CC)
    AC_PATH_PROGS(AR, ar, echo not_ar)
    AC_PATH_PROGS(LD, ld link, echo not_ld)
    AC_PATH_PROGS(STRIP, strip, echo not_strip)
    AC_PATH_PROGS(WINDRES, windres, echo not_windres)
    if test -z "$HOST_CC"; then
	    HOST_CC="$CC"
    fi
    if test -z "$HOST_CFLAGS"; then
	    HOST_CFLAGS="$CFLAGS"
    fi
else
    echo "cross compiling from $host to $target"

    _SAVE_CC="$CC"
    _SAVE_CFLAGS="$CFLAGS"
    _SAVE_LDFLAGS="$LDFLAGS"

    AC_MSG_CHECKING([for $host compiler])
    AC_CHECK_PROGS(HOST_CC, gcc cc /usr/ucb/cc, "")
	if test -z "$HOST_CC"; then
	    AC_MSG_ERROR([no acceptable cc found in \$PATH])
	fi
    AC_MSG_RESULT([$HOST_CC])
    if test -z "$HOST_CFLAGS"; then
	    HOST_CFLAGS="$CFLAGS"
    fi
    if test -z "$HOST_LDFLAGS"; then
	    HOST_LDFLAGS="$LDFLAGS"
    fi

    CC=$_SAVE_CC
    CFLAGS=$_SAVE_CFLAGS
    LDFLAGS=$_SAVE_LDFLAGS

    AC_CHECK_PROGS(CC, $CC "${target_alias}-gcc" "${target}-gcc", echo)
    unset ac_cv_prog_CC
    AC_PROG_CC
    AC_CHECK_PROGS(CXX, $CXX "${target_alias}-g++" "${target}-g++", echo)
    unset ac_cv_prog_CXX
    AC_PROG_CXX

    AC_CHECK_PROGS(RANLIB, $RANLIB "${target_alias}-ranlib" "${target}-ranlib", echo)
    AC_CHECK_PROGS(AR, $AR "${target_alias}-ar" "${target}-ar", echo)
    AC_CHECK_PROGS(AS, $AS "${target_alias}-as" "${target}-as", echo)
    AC_CHECK_PROGS(LD, $LD "${target_alias}-ld" "${target}-ld", echo)
    AC_CHECK_PROGS(STRIP, $STRIP "${target_alias}-strip" "${target}-strip", echo)
    AC_CHECK_PROGS(WINDRES, $WINDRES "${target_alias}-windres" "${target}-windres", echo)
fi

if test "$GCC" = "yes"; then
    GNU_CC=1
fi
if test "$GXX" = "yes"; then
    GNU_CXX=1
fi
if test "`echo | $AS -v 2>&1 | grep -c GNU`" != "0"; then
    GNU_AS=1
fi
rm -f a.out

if test "$cross_compiling"  = "yes"; then
    CROSS_COMPILE=1
else
    CROSS_COMPILE=
fi

dnl ========================================================
dnl Check for gcc -pipe support
dnl ========================================================
AC_MSG_CHECKING([for gcc -pipe support])
if test -n "$GNU_CC" && test -n "$GNU_CXX" && test -n "$GNU_AS"; then
    echo '#include <stdio.h>' > dummy-hello.c
    echo 'int main() { printf("Hello World\n"); exit(0); }' >> dummy-hello.c
    ${CC} -S dummy-hello.c -o dummy-hello.s 2>&5
    cat dummy-hello.s | ${AS} -o dummy-hello.S - 2>&5
    if test $? = 0; then
        _res_as_stdin="yes"
    else
        _res_as_stdin="no"
    fi
    if test "$_res_as_stdin" = "yes"; then
        _SAVE_CFLAGS=$CFLAGS
        CFLAGS="$CFLAGS -pipe"
        AC_TRY_COMPILE( [ #include <stdio.h> ],
            [printf("Hello World\n");],
            [_res_gcc_pipe="yes"],
            [_res_gcc_pipe="no"] )
        CFLAGS=$_SAVE_CFLAGS
    fi
    if test "$_res_as_stdin" = "yes" && test "$_res_gcc_pipe" = "yes"; then
        _res="yes";
        CFLAGS="$CFLAGS -pipe"
        CXXFLAGS="$CXXFLAGS -pipe"
    else
        _res="no"
    fi
    rm -f dummy-hello.c dummy-hello.s dummy-hello.S dummy-hello a.out
    AC_MSG_RESULT([$_res])
else
    AC_MSG_RESULT([no])
fi

fi # SKIP_COMPILER_CHECKS

dnl ========================================================
dnl Checks for programs.
dnl ========================================================
if test -z "$SKIP_PATH_CHECKS"; then
    AC_PATH_PROGS(PERL, perl5 perl, echo not_perl)
elif test -z "$PERL"; then
    PERL=perl
fi

dnl ========================================================
dnl Default platform specific options
dnl ========================================================
OBJ_SUFFIX=o
LIB_SUFFIX=a
LIB_PREFIX=lib
DLL_SUFFIX=so
ASM_SUFFIX=s
MKSHLIB='$(LD) $(DSO_LDOPTS) -o $@'
AR_FLAGS='cr $@'
AS='$(CC)'
ASFLAGS='$(CFLAGS)'

if test -n "$CROSS_COMPILE"; then
    OS_ARCH=`echo $target_os | sed -e 's|/|_|g'`
    OS_RELEASE=
    OS_TEST="${target_cpu}"
    case "${target_os}" in
        linux*)       OS_ARCH=Linux ;;
        solaris*)     OS_ARCH=SunOS OS_RELEASE=5 ;;
        mingw*)     OS_ARCH=WINNT ;;
        darwin*)    OS_ARCH=Darwin ;;
    esac
else
    OS_ARCH=`uname -s | sed -e 's|/|_|g'`
    OS_RELEASE=`uname -r`
    OS_TEST=`uname -m`
fi

if test "$OS_ARCH" = "IRIX64"; then
    OS_ARCH=IRIX
fi

if test "$OS_ARCH" = "Linux"; then
    OS_RELEASE=`echo $OS_RELEASE | sed 's/-.*//'`
    OS_RELEASE=`echo $OS_RELEASE | awk -F. '{ print $1 "." $2 }'`
fi

#######################################################################
# Master "Core Components" macros for getting the OS target           #
#######################################################################

#
# Note: OS_TARGET should be specified on the command line for gmake.
# When OS_TARGET=WIN95 is specified, then a Windows 95 target is built.
# The difference between the Win95 target and the WinNT target is that
# the WinNT target uses Windows NT specific features not available
# in Windows 95. The Win95 target will run on Windows NT, but (supposedly)
# at lesser performance (the Win95 target uses threads; the WinNT target
# uses fibers).
#
# When OS_TARGET=WIN16 is specified, then a Windows 3.11 (16bit) target
# is built. See: win16_3.11.mk for lots more about the Win16 target.
#
# If OS_TARGET is not specified, it defaults to $(OS_ARCH), i.e., no
# cross-compilation.
#

#
# The following hack allows one to build on a WIN95 machine (as if
# s/he were cross-compiling on a WINNT host for a WIN95 target).
# It also accomodates for MKS's uname.exe.  If you never intend
# to do development on a WIN95 machine, you don't need this hack.
#
case "$OS_ARCH" in
WIN95)
    OS_ARCH=WINNT
    OS_TARGET=WIN95
    ;;
Windows_95)
    OS_ARCH=Windows_NT
    OS_TARGET=WIN95
    ;;
Windows_98)
    OS_ARCH=Windows_NT
    OS_TARGET=WIN95
    ;;
CYGWIN_9*|CYGWIN_ME*)
    OS_ARCH='CYGWIN_NT-4.0'
    OS_TARGET=WIN95
    ;;
OS_2)
    OS_ARCH=OS2
    OS_TARGET=OS2
    ;;
esac

#
# On WIN32, we also define the variable CPU_ARCH.
#

case "$OS_ARCH" in
WINNT)
    CPU_ARCH=`uname -p`
    if test "$CPU_ARCH" = "I386"; then
        CPU_ARCH=x86
    fi
    ;;
Windows_NT)
#
# If uname -s returns "Windows_NT", we assume that we are using
# the uname.exe in MKS toolkit.
#
# The -r option of MKS uname only returns the major version number.
# So we need to use its -v option to get the minor version number.
# Moreover, it doesn't have the -p option, so we need to use uname -m.
#
    OS_ARCH=WINNT
    OS_MINOR_RELEASE=`uname -v`
    if test "$OS_MINOR_RELEASE" = "00"; then
        OS_MINOR_RELEASE=0
    fi
    OS_RELEASE="${OS_RELEASE}.${OS_MINOR_RELEASE}"
    CPU_ARCH=`uname -m`
    #
    # MKS's uname -m returns "586" on a Pentium machine.
    #
    if echo "$CPU_ARCH" | grep -c 86 >/dev/null; then
        CPU_ARCH=x86
    fi
    ;;
CYGWIN32_NT|CYGWIN_NT*|MINGW*_NT*)
#
# If uname -s returns "CYGWIN_NT-4.0", we assume that we are using
# the uname.exe in the Cygwin tools.
# Prior to the Beta 20 release, Cygwin was called GNU-Win32.
# If uname -s returns "CYGWIN32/NT", we assume that we are using
# the uname.exe in the GNU-Win32 tools.
# If uname -s returns MINGW32_NT-5.1, we assume that we are using
# the uname.exe in the MSYS tools.
#
    OS_RELEASE=`expr $OS_ARCH : '.*NT-\(.*\)'`
    OS_ARCH=WINNT
    CPU_ARCH=`uname -m`
    #
    # Cygwin's uname -m returns "i686" on a Pentium Pro machine.
    #
    if echo "$CPU_ARCH" | grep -c 86 >/dev/null; then
        CPU_ARCH=x86
    fi
    ;;
esac

if test -n "$MOZILLA_CLIENT" && test "$OS_ARCH" = "WINNT"; then
    OS_TARGET=WIN95
    if test -n "$MOZ_DEBUG"; then
        USE_DEBUG_RTL=1
    fi
fi
if test -z "$OS_TARGET"; then
    OS_TARGET=$OS_ARCH
fi
if test "$OS_TARGET" = "WIN95"; then
    OS_RELEASE="4.0"
fi
if test "$OS_TARGET" = "WIN16"; then
    OS_RELEASE=
fi

dnl ========================================================
dnl = Mac OS X SDK support
dnl ========================================================
AC_ARG_WITH(macos-sdk,
    [  --with-macos-sdk=dir    Location of platform SDK to use (Mac OS X only)],
    MACOS_SDK_DIR=$withval)

dnl ========================================================
dnl Enable high-memory support on OS/2 by default.
dnl ========================================================
AC_ARG_ENABLE(os2-high-mem,
    [  --disable-os2-high-mem Disable high-memory support on OS/2],
    [ if test "$enableval" = "no"; then
        MOZ_OS2_HIGH_MEMORY=
      else
        MOZ_OS2_HIGH_MEMORY=1
      fi ])

dnl ========================================================
dnl Override of system specific host options
dnl ========================================================
case "$host" in
*-mingw*)
    NSINSTALL=nsinstall
    WIN_TOP_SRC=`cd $srcdir && pwd -W`
    ;;
*-cygwin*|*-msvc*|*-mks*)
    CYGWIN_WRAPPER='sh $(topsrcdir)/config/cygwin-wrapper'
    NSINSTALL='$(CYGWIN_WRAPPER) nsinstall'
    if test "`${PERL} -v | grep -c cygwin  2>/dev/null`" = 0; then
        PERL='$(CYGWIN_WRAPPER) perl'
    fi
    WIN_TOP_SRC=`cygpath -w $srcdir | sed -e 's|\\\\|/|g'`
    ;;
*-beos*)
    HOST_CFLAGS="$HOST_CFLAGS -DXP_BEOS -DBeOS -DBEOS -D_POSIX_SOURCE"
    ;;
*os2*)
    ;;
*)
    HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
    ;;
esac

dnl ========================================================
dnl Check for --with-rpath and user supplied rpath
dnl ========================================================
DEFAULT_RPATHFLAG=..:../lib:../../lib:../../../lib:../../../../lib
AC_ARG_WITH(rpath,
    [  --with-rpath[[=dir]]    Build the shared libs and cmd lines progs with an RPATH (default dir is ..:../lib:../../lib:../../../lib:../../../../lib)],
[
    if test "$withval" = "yes" ; then # set default
       RPATHFLAG="$DEFAULT_RPATHFLAG"
    elif test -n "$withval" ; then # user supplied
       RPATHFLAG="$withval"
    fi
])

dnl ========================================================
dnl Override of system specific target options
dnl ========================================================
case "$target" in

*-aix*)
    AC_DEFINE(XP_UNIX)
    AC_DEFINE(AIX)
    AC_DEFINE(SYSV)
    DSO_LDOPTS='-brtl -bM:SRE -bnoentry -bexpall -blibpath:/usr/lib:/lib'
    AC_CHECK_HEADER(sys/atomic_op.h, AC_DEFINE(AIX_HAVE_ATOMIC_OP_H))
    case "${target_os}" in
    aix3.2*)
        AC_DEFINE(AIX_RENAME_SELECT)
        AC_DEFINE(_PR_NO_LARGE_FILES)
        ;;
    aix4.1*)
        AC_DEFINE(AIX_TIMERS)
        AC_DEFINE(_PR_NO_LARGE_FILES)
        AC_DEFINE(AIX4_1)
        MKSHLIB=
        DSO_LDOPTS=
        ;;
    aix4.2*)
        AC_DEFINE(AIX_TIMERS)
        AC_DEFINE(_PR_HAVE_OFF64_T)
        ;;
    aix4.3*)
        AC_DEFINE(AIX_TIMERS)
        AC_DEFINE(_PR_HAVE_OFF64_T)
        AC_DEFINE(AIX4_3)
        AC_DEFINE(HAVE_SOCKLEN_T)
        AC_DEFINE(HAVE_FCNTL_FILE_LOCKING)
        USE_IPV6=1
        ;;
    *)
        AC_DEFINE(AIX_TIMERS)
        AC_DEFINE(_PR_HAVE_OFF64_T)
        AC_DEFINE(HAVE_SOCKLEN_T)
        AC_DEFINE(HAVE_FCNTL_FILE_LOCKING)
        USE_IPV6=1
        ;;
    esac
    CFLAGS="$CFLAGS -qro -qroconst"
    if echo "$CC" | grep -c xlC_r; then
        CFLAGS="$CFLAGS -qarch=com"
    fi
    AIX_WRAP='$(DIST)/lib/aixwrap.o'
    AIX_TMP='./_aix_tmp.o'
    if test -n "$USE_64"; then
        OBJECT_MODE=64
    fi
    RESOLVE_LINK_SYMBOLS=1
    ;;
        
*-beos*)
    AC_DEFINE(XP_BEOS)
    AC_DEFINE(BeOS)
    AC_DEFINE(BEOS)
    AC_DEFINE(_POSIX_SOURCE)
    DSO_LDOPTS=-nostart
    USE_BTHREADS=1
    RESOLVE_LINK_SYMBOLS=1
    case "${target_cpu}" in
    i*86)
        _OPTIMIZE_FLAGS=-O2
        _DEBUG_FLAGS='-gdwarf-2 -O0'
        MKSHLIB='$(CCC) $(DSO_LDOPTS) -o $@'
        AC_CHECK_LIB(bind, gethostbyaddr, [OS_LIBS="$OS_LIBS -lbind -lsocket"])
        ;;
    powerpc)
        CC=mwcc
        CCC=mwcc
        LD=mwld
        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'
        _OPTIMIZE_FLAGS=-O2    
        _DEBUG_FLAGS='-g -O0'
        ;;
    esac
    ;;

*-bsdi*)
    AC_DEFINE(XP_UNIX)
    AC_DEFINE(BSDI)
    AC_DEFINE(NEED_BSDREGEX)

    CFLAGS="$CFLAGS -Wall -Wno-format"
    CXXFLAGS="$CXXFLAGS -Wall -Wno-format"

    if echo "$OS_TEST" | grep -c 86 >/dev/null; then
        CPU_ARCH=x86
    elif echo "$OS_TEST" | grep -c sparc >/dev/null; then 
        CPU_ARCH=sparc
    fi

    DSO_LDOPTS=-r

    case "$target_os" in
    bsdi1.1*)
        AC_DEFINE(_PR_BSDI_JMPBUF_IS_ARRAY)
        AC_DEFINE(_PR_STAT_HAS_ONLY_ST_ATIME)
        AC_DEFINE(_PR_NEED_H_ERRNO)
        MKSHLIB=
        DSO_CFLAGS=
        DSO_LDOPTS=
        ;;

    bsdi2.1*)
        AC_DEFINE(_PR_TIMESPEC_HAS_TS_SEC)
        AC_DEFINE(_PR_BSDI_JMPBUF_IS_ARRAY)
        AC_DEFINE(HAVE_DLL)
        AC_DEFINE(USE_DLFCN)
        AC_DEFINE(_PR_STAT_HAS_ST_ATIMESPEC)
        ;;

    bsdi4.*)
        AC_DEFINE(_PR_SELECT_CONST_TIMEVAL)
        AC_DEFINE(_PR_BSDI_JMPBUF_IS_STRUCT)
        AC_DEFINE(HAVE_DLL)
        AC_DEFINE(USE_DLFCN)
        AC_DEFINE(_PR_STAT_HAS_ST_ATIMESPEC)
        MKSHLIB='$(CC) -o $@ $(DSO_LDOPTS)'
        DSO_CFLAGS=-fPIC
        DSO_LDOPTS='-shared -soname $(@:$(OBJDIR)/%.so=%.so)'
        STRIP="$STRIP -d"
        case "$target_os" in
        bsdi4.2*)
            AC_DEFINE(_PR_HAVE_GETPROTO_R)
            AC_DEFINE(_PR_HAVE_GETPROTO_R_POINTER)
            ;;
        esac
        ;;
    *)
        AC_DEFINE(_PR_SELECT_CONST_TIMEVAL)
        AC_DEFINE(_PR_BSDI_JMPBUF_IS_STRUCT)
        AC_DEFINE(HAVE_DLL)
        AC_DEFINE(USE_DLFCN)
        AC_DEFINE(_PR_STAT_HAS_ST_ATIMESPEC)
        ;;
    esac

    ;;

*-darwin*)
    AC_DEFINE(XP_UNIX)
    AC_DEFINE(DARWIN)
    AC_DEFINE(HAVE_BSD_FLOCK)
    CFLAGS="$CFLAGS -Wmost -fno-common"
    case "${target_cpu}" in
        i*86*)
            AC_DEFINE(i386)
            CPU_ARCH=i386
            ;;
        *)
            AC_DEFINE(ppc)
            CPU_ARCH=ppc
            ;;
    esac
    DSO_LDOPTS='-dynamiclib -compatibility_version 1 -current_version 1 -all_load -install_name @executable_path/$@'
    MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
    STRIP="$STRIP -x -S"
    DLL_SUFFIX=dylib
    USE_PTHREADS=1

    dnl MACOS_SDK_DIR will be set to the SDK location whenever one is
    dnl in use.  NEXT_ROOT will be set and exported if it's needed for
    dnl ld.

    if test "$MACOS_SDK_DIR"; then
        dnl Sync this section with the one in Mozilla's top level.
        if test ! -d "$MACOS_SDK_DIR"; then
            AC_MSG_ERROR([SDK not found.  When using --with-macos-sdk, you must
specify a valid SDK.  SDKs are installed when the optional cross-development
tools are selected during the Xcode/Developer Tools installation.])
        fi

        changequote(,)
        CC_VERSION=`$CC -v 2>&1 | grep 'gcc version'`
        GCC_VERSION_FULL=`echo $CC_VERSION | $PERL -pe 's/^.*gcc version ([^ ]*).*/$1/'`
        GCC_VERSION=`echo $GCC_VERSION_FULL | $PERL -pe '(split(/\./))[0]>=4&&s/(^\d*\.\d*).*/$1/;'`
        changequote([,])
        GCC_VERSION_MAJOR=`echo $GCC_VERSION_FULL | $PERL -pe 's/(^\d*).*/$1/;'`
        if test "$GCC_VERSION_MAJOR" -lt "4" ; then
            SDK_C_FRAMEWORK="-F${MACOS_SDK_DIR}/System/Library/Frameworks"
            if test -d "${MACOS_SDK_DIR}/Library/Frameworks" ; then
                SDK_C_FRAMEWORK="$SDK_C_FRAMEWORK -F${MACOS_SDK_DIR}/Library/Frameworks"
            fi

            SDK_C_INCLUDE="-isystem ${MACOS_SDK_DIR}/usr/include/gcc/darwin/${GCC_VERSION} -isystem ${MACOS_SDK_DIR}/usr/include ${SDK_C_FRAMEWORK}"

            CFLAGS="$CFLAGS -nostdinc ${SDK_C_INCLUDE}"

            dnl CPP needs to be set for AC_CHECK_HEADER.
            CPP="$CPP -nostdinc ${SDK_C_INCLUDE}"

            dnl ld support for -syslibroot is compiler-agnostic, but only
            dnl available on Tiger.  Although it's possible to switch on
            dnl the build host's OS release to use ld -syslibroot when
            dnl available, ld -syslibroot cause warnings as long as
            dnl NEXT_ROOT is set.  NEXT_ROOT should be set because both
            dnl both the compiler and linker use it.
            dnl
            dnl LDFLAGS is for the utilities built in config (now and
            dnl nsinstall).  DSO_LDOPTS is used when linking shared
            dnl libraries.
            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}"
            LDFLAGS="${MACOS_SDK_LIBS} $LDFLAGS"
            DSO_LDOPTS="${MACOS_SDK_LIBS} $DSO_LDOPTS"
            export NEXT_ROOT=$MACOS_SDK_DIR

            if test -n "$CROSS_COMPILE" ; then
                dnl NEXT_ROOT will be in the environment, but it
                dnl shouldn't be set for the build host.  HOST_CXX is
                dnl presently unused.
                HOST_CC="NEXT_ROOT= $HOST_CC"
                HOST_CXX="NEXT_ROOT= $HOST_CXX"
            fi
        else
            dnl gcc >= 4.0 uses different paths than above, but knows
            dnl how to find them itself.
            CFLAGS="$CFLAGS -isysroot ${MACOS_SDK_DIR}"

            dnl CPP needs to be set for AC_CHECK_HEADER.
            CPP="$CPP -isysroot ${MACOS_SDK_DIR}"

            dnl If gcc >= 4.0.0, we're guaranteed to be on Tiger, which
            dnl has an ld that supports -syslibroot.  Don't set
            dnl NEXT_ROOT because it will be ignored and cause
            dnl warnings when -syslibroot is specified.
            dnl
            dnl Both LDFLAGS and DSO_LDOPTS are set here, see the
            dnl gcc < 4.0 case for the explanation.
            if test "$GCC_VERSION_FULL" != "4.0.0" ; then
                dnl gcc > 4.0.0 will pass -syslibroot to ld automatically
                dnl based on the -isysroot it receives.
                LDFLAGS="$LDFLAGS -isysroot ${MACOS_SDK_DIR}"
                DSO_LDOPTS="$DSO_LDOPTS -isysroot ${MACOS_SDK_DIR}"
            else
                dnl gcc 4.0.0 doesn't pass -syslibroot to ld, it needs
                dnl to be explicit.
                LDFLAGS="$LDFLAGS -Wl,-syslibroot,${MACOS_SDK_DIR}"
                DSO_LDOPTS="$DSO_LDOPTS -Wl,-syslibroot,${MACOS_SDK_DIR}"
            fi
        fi
    fi
    ;;

*-dgux*)
    AC_DEFINE(XP_UNIX)
    AC_DEFINE(_PR_LOCAL_THREADS_ONLY)
    AC_DEFINE(SVR4)
    AC_DEFINE(SYSV)
    AC_DEFINE(DGUX)
    AC_DEFINE(_DGUX_SOURCE)
    AC_DEFINE(_POSIX4A_DRAFT6_SOURCE)
    DSO_LDOPTS=-G
    _OPTIMIZE_FLAGS=-O2
    _DEBUG_FLAGS=
    ;;

*-dragonfly*)
    if test -z "$USE_NSPR_THREADS"; then
        USE_PTHREADS=1
    fi
    AC_DEFINE(XP_UNIX)
    AC_DEFINE(DRAGONFLY)
    DSO_CFLAGS=-fPIC
    DSO_LDOPTS='-shared'
	;;

*-freebsd*)
    if test -z "$USE_NSPR_THREADS"; then
        USE_PTHREADS=1
    fi
    AC_DEFINE(XP_UNIX)
    AC_DEFINE(FREEBSD)
    AC_DEFINE(HAVE_BSD_FLOCK)
    CFLAGS="$CFLAGS $(DSO_CFLAGS) -ansi -Wall"
    MOZ_OBJFORMAT=`test -x /usr/bin/objformat && /usr/bin/objformat || echo elf`
    if test "$MOZ_OBJFORMAT" = "elf"; then
        DLL_SUFFIX=so
    else
        DLL_SUFFIX=so.1.0
    fi
    DSO_CFLAGS=-fPIC
    DSO_LDOPTS=-Bshareable
    ;;

*-hpux*)
    AC_DEFINE(XP_UNIX)
    AC_DEFINE(HPUX)
    AC_DEFINE(_HPUX_SOURCE)
    if test "$OS_TEST" = "ia64" ; then
        AC_DEFINE(ia64)
        DLL_SUFFIX=so
    else
        AC_DEFINE(hppa)
        DLL_SUFFIX=sl
    fi
    DSO_LDOPTS='-b +h $(notdir $@)'
    if test -z "$GNU_CC"; then
        CC="$CC -Ae"
        CXX="$CXX -ext"
        if test "$OS_RELEASE" = "B.11.23"; then
            CFLAGS="$CFLAGS +Olit=all"
            CXXFLAGS="$CXXFLAGS +Olit=all"
        else
            CFLAGS="$CFLAGS +ESlit"
            CXXFLAGS="$CXXFLAGS +ESlit"
        fi
        DSO_CFLAGS=+Z
    else
        DSO_CFLAGS=-fPIC
    fi

    if test -n "$MOZILLA_CLIENT"; then
        DEFAULT_IMPL_STRATEGY=_EMU
    fi

    if echo "$OS_RELEASE" | grep ^A.09 >/dev/null; then
        AC_DEFINE(_PR_NEED_H_ERRNO)
        AC_DEFINE(HPUX9)
        DEFAULT_IMPL_STRATEGY=_EMU
    	USE_NSPR_THREADS=1
    fi

    if echo "$OS_RELEASE" | egrep '^(A.09|B.10)' >/dev/null; then
        AC_DEFINE(_PR_NO_LARGE_FILES)
    fi

    if echo "$OS_RELEASE" | egrep '^(B.10.10|B.10.20)' >/dev/null; then
        AC_DEFINE(_PR_NEED_H_ERRNO)
    fi

    if echo "$OS_RELEASE" | egrep '^(B.10.10|B.10.20)' >/dev/null; then
        AC_DEFINE(HAVE_INT_LOCALTIME_R)
    fi

    if echo "$OS_RELEASE" | egrep '^(B.10.30|B.11.00|B.11.11|B.11.23)' >/dev/null; then
        AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
    fi

    if test "$OS_RELEASE" = "B.10.01"; then
        AC_DEFINE(HPUX10)
        DEFAULT_IMPL_STRATEGY=_EMU
    fi

    if test "$OS_RELEASE" = "B.10.10"; then
        AC_DEFINE(HPUX10)
        AC_DEFINE(HPUX10_10)
        DEFAULT_IMPL_STRATEGY=_PTH
    fi

    if test "$OS_RELEASE" = "B.10.20"; then
        AC_DEFINE(HPUX10)
        AC_DEFINE(HPUX10_20)
        if test -z "$GNU_CC"; then
            CFLAGS="$CFLAGS +DAportable +DS1.1"
            CXXFLAGS="$CXXFLAGS +DAportable +DS1.1"
        fi
        DEFAULT_IMPL_STRATEGY=_PTH
    fi

    if test "$OS_RELEASE" = "B.10.30"; then
        AC_DEFINE(HPUX10)
        AC_DEFINE(HPUX10_30)
        if test -z "$GNU_CC"; then
            CFLAGS="$CFLAGS +DAportable +DS1.1"
            CXXFLAGS="$CXXFLAGS +DAportable +DS1.1"
        fi
        DEFAULT_IMPL_STRATEGY=_PTH
    fi

    if echo "$OS_RELEASE" | egrep '^(B.11.00|B.11.11)' >/dev/null; then
        AC_DEFINE(HPUX10)
        AC_DEFINE(HPUX11)
        AC_DEFINE(_LARGEFILE64_SOURCE)
        AC_DEFINE(_PR_HAVE_OFF64_T)
        AC_DEFINE(HAVE_FCNTL_FILE_LOCKING)
        if test -z "$GNU_CC"; then
            if test -z "$USE_64"; then
                CFLAGS="$CFLAGS +DAportable +DS2.0"
                CXXFLAGS="$CXXFLAGS +DAportable +DS2.0"
            else
                CFLAGS="$CFLAGS +DA2.0W +DS2.0"
                CXXFLAGS="$CXXFLAGS +DA2.0W +DS2.0"
            fi
        fi
        DEFAULT_IMPL_STRATEGY=_PTH
    fi

    if test "$OS_RELEASE" = "B.11.23"; then
        AC_DEFINE(HPUX10)
        AC_DEFINE(HPUX11)
        AC_DEFINE(_LARGEFILE64_SOURCE)
        AC_DEFINE(_PR_HAVE_OFF64_T)
        AC_DEFINE(HAVE_FCNTL_FILE_LOCKING)
        if test -z "$GNU_CC"; then
            if test -z "$USE_64"; then
                CFLAGS="$CFLAGS +DD32"
                CXXFLAGS="$CXXFLAGS +DD32"
            else
                CFLAGS="$CFLAGS +DD64"
                CXXFLAGS="$CXXFLAGS +DD64"
            fi
        fi
        DEFAULT_IMPL_STRATEGY=_PTH
    fi

    if test "$DEFAULT_RPATHFLAG" = "$RPATHFLAG" ; then
       if test "$OS_RELEASE" = "B.11.23" -o "$OS_RELEASE" = "B.11.11" ; then
          # add ORIGIN to default rpath
          RPATHFLAG="\\\$\$ORIGIN/../lib:\\\$\$ORIGIN/../../lib:$RPATHFLAG"
       fi
    fi

    if test "$DEFAULT_IMPL_STRATEGY" = "_EMU"; then
        USE_NSPR_THREADS=1
        USE_PTHREADS=
        USE_USER_THREADS=
    elif test "$DEFAULT_IMPL_STRATEGY" = "_PTH"; then
        USE_PTHREADS=1
        if test "$USE_NSPR_THREADS"; then
            USE_PTHREADS=
        fi
        if test "$USE_USER_PTHREADS"; then
            USE_PTHREADS=
        fi
    fi

    ;;

*-irix*)
    AC_DEFINE(XP_UNIX)
    AC_DEFINE(IRIX)
    AC_DEFINE(SVR4)
    AC_DEFINE(_SGI_MP_SOURCE)
    AC_DEFINE(HAVE_FCNTL_FILE_LOCKING)
    DSO_LDOPTS='-rdata_shared -shared'
    MKSHLIB='$(LD) $(DSO_LDOPTS) -soname $(notdir $@) -o $@'
    STRIP="$STRIP -f"
    RESOLVE_LINK_SYMBOLS=1
    case "${target_os}" in
    irix6*)
        AC_DEFINE(IRIX6)
        USE_PTHREADS=1
        USE_N32=1
        ;;
    irix5*)
        AC_DEFINE(IRIX5)
        USE_NSPR_THREADS=1
        ;;
    *)
        USE_PTHREADS=1
        USE_N32=1
        ;;
    esac
    if test "$GNU_CC"; then
        dnl
        dnl If we are using gcc with native binutils, we need to
        dnl suppress the
        dnl #lineno "filename" num num
        dnl lines, which confuse IRIX native as.  Add -Wp,-P to the
        dnl gcc command line, which passes -P to the preprocessor.
        dnl
	    AS='$(CC) -Wp,-P -x assembler-with-cpp -D_ASM -mips2 $(INCLUDES)'
	    CFLAGS="$CFLAGS -Wall -Wno-format"
	    _OPTIMIZE_FLAGS="-O6"
    else
	    if test -n "$USE_N32"; then
		AS='as -D_ASM $(INCLUDES) -n32'
	    else
		AS='as -D_ASM $(INCLUDES)'
	    fi
	    CFLAGS="$CFLAGS -fullwarn -xansi"
	    if test "$USE_N32"; then
	        _OPTIMIZE_FLAGS="-O -OPT:Olimit=4000"
	    else
	        _OPTIMIZE_FLAGS="-O -Olimit 4000"
	    fi
	    if test "$USE_MDUPDATE"; then
                CFLAGS="$CFLAGS -MDupdate \$(DEPENDENCIES)"
	    fi
	    case "$target}" in
	    *-irix6.*)
	        CFLAGS="$CFLAGS -multigot"
	        DSO_LDOPTS="$DSO_LDOPTS -no_unresolved"
	        if test "$USE_N32"; then
		        CFLAGS="$CFLAGS -n32 -woff 1209"
		        DSO_LDOPTS="$DSO_LDOPTS -n32"
	        else
		        if test "$USE_64"; then
		            CFLAGS="$CFLAGS -64"
		        else
		            CFLAGS="$CFLAGS -32"
		        fi
	        fi
	        ;;
	    *)
	        CFLAGS="$CFLAGS -xgot"
	        ;;
	    esac
    fi
    if test "${target_os}" = "irix5.3"; then
	    AC_DEFINE(IRIX5_3)
    fi
    case "${target_os}" in
	irix6.5)
	    if test -z "$GNU_CC"; then
		    CFLAGS="$CFLAGS -mips3"
	    fi
	    AC_DEFINE(_PR_HAVE_GETPROTO_R)
	    AC_DEFINE(_PR_HAVE_GETPROTO_R_POINTER)
	    AC_DEFINE(_PR_HAVE_SGI_PRDA_PROCMASK)
	    ;;
	irix5*)
	    ;;
	*)
	    AC_DEFINE(_PR_HAVE_SGI_PRDA_PROCMASK)
	    ;;
	esac
    ;;

*-linux*)
    if test -z "$USE_NSPR_THREADS"; then
        USE_PTHREADS=1
    fi
    AC_DEFINE(XP_UNIX)
    AC_DEFINE(_POSIX_SOURCE)
    AC_DEFINE(_BSD_SOURCE)
    AC_DEFINE(_SVID_SOURCE)
    AC_DEFINE(_LARGEFILE64_SOURCE)
    AC_DEFINE(HAVE_FCNTL_FILE_LOCKING)
    AC_DEFINE(LINUX)
    AC_DEFINE(linux)
    LD='$(CC)'
    CFLAGS="$CFLAGS -ansi -Wall"
    CXXFLAGS="$CXXFLAGS -ansi -Wall"
    MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
    DSO_CFLAGS=-fPIC
    DSO_LDOPTS='-shared -Wl,-soname -Wl,$(notdir $@)'
    OS_LIBS="$OS_LIBS -lc"
    _OPTIMIZE_FLAGS=-O2
    _DEBUG_FLAGS="-g -fno-inline"  # most people on linux use gcc/gdb, and that
                                   # combo is not yet good at debugging inlined
                                   # functions (even when using DWARF2 as the
                                   # debugging format)
    case "$OS_TEST" in
    i*86)
        CPU_ARCH=x86
        ;;
    *)
        CPU_ARCH=$OS_TEST
        ;;
    esac

    case "${target_cpu}" in
    alpha)
        AC_DEFINE(_ALPHA_)
        AC_DEFINE(__alpha)
        CFLAGS="$CFLAGS -mieee"
        CXXFLAGS="$CXXFLAGS -mieee"
        ;;
    i*86)
        AC_DEFINE(i386)
        ;;
    ia64)
        ;;
    m68k)
        CFLAGS="$CFLAGS -m68020-40"
        CXXFLAGS="$CXXFLAGS -m68020-40"
        #
        # gcc on Linux/m68k either has a bug or triggers a code-sequence
        # bug in the 68060 which causes gcc to crash.  The simplest way to
        # avoid this is to enable a minimum level of optimization.
        #
        _DEBUG_FLAGS="$_DEBUG_FLAGS -O"
        ;;
    esac    
    ;;

*-mingw*|*-cygwin*|*-msvc*|*-mks*)
    AC_DEFINE(XP_PC)
    AC_DEFINE(WIN32)
    AC_DEFINE(_WINDOWS)
    RESOLVE_LINK_SYMBOLS=1
    PROG_SUFFIX=.exe
    if test -n "$GNU_CC"; then
        CC="$CC -mno-cygwin"
        CXX="$CXX -mno-cygwin"
        DLL_SUFFIX=dll
        MKSHLIB='$(CC) -shared -Wl,--export-all-symbols -Wl,--out-implib -Wl,$(IMPORT_LIBRARY) -o $@'
        # Use temp file for windres (bug 213281)
        RC="$WINDRES -O coff --use-temp-file"
    else
        CC=cl
        CXX=cl
        LD=link
        # if the lib program is available, use it, otherwise use link /lib
        AC_CHECK_PROG(HAVE_MSVC_LIB, lib, 1)
        if test "$HAVE_MSVC_LIB" = "1" ; then
            AR='lib -NOLOGO -OUT:"$@"'
        else
            AR='$(LD) /lib -NOLOGO -OUT:"$@"'
        fi

        AR_FLAGS=
        RANLIB='echo not_ranlib'
        STRIP='echo not_strip'
        RC=rc.exe
        GARBAGE='$(OBJDIR)/vc20.pdb $(OBJDIR)/vc40.pdb'
	    OBJ_SUFFIX=obj
	    LIB_SUFFIX=lib
	    LIB_PREFIX=
	    DLL_SUFFIX=dll
        
        # Determine compiler version
        changequote(,)
        _MSVC_VER_FILTER='s|.* \([0-9]\+\.[0-9]\+\.[0-9]\+\(\.[0-9]\+\)\?\).*|\1|p'
        changequote([,])

        CC_VERSION=`"${CC}" -v 2>&1 | sed -ne "$_MSVC_VER_FILTER"`
        _CC_MAJOR_VERSION=`echo ${CC_VERSION} | awk -F\. '{ print $1 }'`
        _CC_MINOR_VERSION=`echo ${CC_VERSION} | awk -F\. '{ print $2 }'`
        _CC_RELEASE=`echo ${CC_VERSION} | awk -F\. '{ print $3 }'`
        _CC_BUILD=`echo ${CC_VERSION} | awk -F\. '{ print $4 }'`
        _MSC_VER=${_CC_MAJOR_VERSION}${_CC_MINOR_VERSION}

        if test "$_CC_MAJOR_VERSION" -eq "14"; then
          dnl -DYNAMICBASE is only supported on VC8SP1 or newer,
          dnl so be very specific here!
          dnl VC8 is 14.00.50727.42, VC8SP1 is 14.00.50727.762
          if test "$_CC_RELEASE" -gt 50727 -o \
                  \( "$_CC_RELEASE" -eq 50727 -a "$_CC_BUILD" -ge 762 \); then
            _USE_DYNAMICBASE=1
          fi
        elif test $_CC_MAJOR_VERSION -ge 15; then
          _USE_DYNAMICBASE=1    
        fi

        if test -n "$_USE_DYNAMICBASE"; then
          DLLFLAGS="$DLLFLAGS -DYNAMICBASE"
        fi

        CFLAGS="$CFLAGS -W3 -nologo -GF -Gy"
        DLLFLAGS="$DLLFLAGS -OUT:\"\$@\""

        _DEBUG_FLAGS=-Z7
        _OPTIMIZE_FLAGS=-O2
        if test -z "$MOZ_OPTIMIZE"; then
            CFLAGS="$CFLAGS -Od"
        fi

        if test -n "$USE_DEBUG_RTL"; then
            CFLAGS="$CFLAGS -MDd"
        else
            CFLAGS="$CFLAGS -MD"
        fi

        if test -n "$MOZ_DEBUG"; then
            AC_DEFINE(_DEBUG)
        else
            DEFINES="$DEFINES -U_DEBUG"
        fi

        if test -n "$MOZ_OPTIMIZE"; then
            if test -n "$MOZ_DEBUG_SYMBOLS"; then
                _OPTIMIZE_FLAGS="$_OPTIMIZE_FLAGS -Zi"
                DLLFLAGS="$DLLFLAGS -DEBUG -OPT:REF"
                LDFLAGS="$LDFLAGS -DEBUG -OPT:REF"
            fi
        fi

        if test -n "$MOZ_DEBUG"; then
            DLLFLAGS="$DLLFLAGS -DEBUG"
            LDFLAGS="$LDFLAGS -DEBUG"
        fi
        
        OS_DLLFLAGS='-nologo -DLL -SUBSYSTEM:WINDOWS'
        if test "$_MSC_VER" -le "1200" -a -z "$MOZ_DEBUG_SYMBOLS"; then
            OS_DLLFLAGS="$OS_DLLFLAGS -PDB:NONE"
        fi

        if test "$OS_TARGET" = "WINNT"; then
            CFLAGS="$CFLAGS -GT"
            if test "$CPU_ARCH" = "x86"; then
                CFLAGS="$CFLAGS -G5"
            fi
        fi
    fi # GNU_CC

    if test -n "$USE_STATIC_TLS"; then
        AC_DEFINE(_PR_USE_STATIC_TLS)
    fi

    if test "$OS_TARGET" = "WINNT"; then
        AC_DEFINE(WINNT)
    else
        AC_DEFINE(WIN95)
        # undefine WINNT as some versions of mingw gcc define it by default
        DEFINES="$DEFINES -UWINNT"
        AC_DEFINE(_PR_GLOBAL_THREADS_ONLY)
    fi

    case "$OS_TARGET" in
    WINNT)
	    ;;
    WIN95)
	    ;;
    WIN16)
	    ;;
    *)
	    AC_MSG_ERROR([Missing OS_TARGET for ${target}.  Use --enable-win32-target to set.])
   	;;
    esac

    case "$target_cpu" in
    i*86)
	    if test -n "$USE_64"; then
		AC_DEFINE(_AMD64_)
		AC_DEFINE(_M_AMD64)
	    else
		AC_DEFINE(_X86_)
	    fi
	    ;;
    alpha)
	    AC_DEFINE(_ALPHA_)
   	    ;;
    mips)
	    AC_DEFINE(_MIPS_)
	    ;;
    x86_64)
	    AC_DEFINE(_AMD64_)
	    AC_DEFINE(_M_AMD64)
	    ;;
    *)
	    AC_DEFINE(_CPU_ARCH_NOT_DEFINED)
	    ;;
    esac

    if test -n "$USE_64"; then
	AC_DEFINE(_WIN64)
    fi
    ;;

*-ncr-sysv*)
    AC_DEFINE(XP_UNIX)
    AC_DEFINE(SVR4)
    AC_DEFINE(SYSV)
    AC_DEFINE(NCR)
    USE_NSPR_THREADS=1
    if test "$OS_RELEASE" = "2.03"; then
        AC_DEFINE(_PR_STAT_HAS_ST_ATIM)
    else
        AC_DEFINE(_PR_STAT_HAS_ST_ATIM_UNION)
    fi

    if test -z "$GNU_CC"; then
        CFLAGS="$CFLAGS -Hnocopyr"
        CXXFLAGS="$CXXFLAGS -Hnocopyr"
    else
        CFLAGS="$CFLAGS -fPIC -Wall"
        CXXFLAGS="$CXXFLAGS -fPIC -Wall"
        DSO_LDOPTS=-G
    fi
    ;;

mips-nec-sysv*)
    AC_DEFINE(XP_UNIX)
    AC_DEFINE(SVR4)
    AC_DEFINE(__SVR4)
    AC_DEFINE(NEC)
    AC_DEFINE(nec_ews)
    USE_NSPR_THREADS=1
    if test -z "$GNU_CC"; then
        CC='$(NSDEPTH)/build/hcc cc -Xa -KGnum=0 -KOlimit=4000'
        CXX=g++
    fi
    OS_LIBS="$OS_LIBS -lsocket -lnsl -ldl"
    DSO_LDOPTS=-G
    ;;

*-netbsd*)
    AC_DEFINE(XP_UNIX)
    AC_DEFINE(NETBSD)
    AC_DEFINE(HAVE_BSD_FLOCK)
    USE_NSPR_THREADS=1

    DSO_CFLAGS='-fPIC -DPIC'
    CFLAGS="$CFLAGS -ansi -Wall"
    CXXFLAGS="$CXXFLAGS -ansi -Wall"
    MKSHLIB='$(CC) -o $@ $(DSO_LDOPTS)'

    if test -z "$OBJECT_FMT"; then
        if echo __ELF__ | ${CC-cc} -E - | grep -q __ELF__ 2>/dev/null; then
            OBJECT_FMT=a.out
            DLL_SUFFIX=so.1.0
            DSO_LDOPTS='-shared'
        else
            OBJECT_FMT=ELF
            DLL_SUFFIX=so
            DSO_LDOPTS='-shared -Wl,-soname,$(notdir $@)'
        fi
    fi

    if test "$LIBRUNPATH"; then
        DSO_LDOPTS="$DSO_LDOPTS -Wl,-R$LIBRUNPATH"
    fi
    ;;

mips-sony-newsos*)
    AC_DEFINE(XP_UNIX)
    AC_DEFINE(SONY)
    AC_DEFINE(SYSV)
    AC_DEFINE(SVR4)
    AC_DEFINE(__svr4)
    AC_DEFINE(__svr4__)
    AC_DEFINE(HAVE_SVID_GETTOD)
    USE_NSPR_THREADS=1
    CFLAGS="$CFLAGS -Xa -fullwarn"
    CXXFLAGS="$CXXFLAGS -Xa -fullwarn"
    DSO_LDOPTS=-G
    ;;

*-nextstep*|*-openstep*)
    AC_DEFINE(XP_UNIX)
    AC_DEFINE(NEXTSTEP)
    AC_DEFINE(HAVE_BSD_FLOCK)
    AC_DEFINE(_POSIX_SOURCE)
    CFLAGS="$CFLAGS -Wall -fno-common -traditional-cpp -posix"
    CXXFLAGS="$CXXFLAGS -Wall -fno-common -traditional-cpp -posix"
    USE_NSPR_THREADS=1
    DLL_SUFFIX=dylib
    ;;


*-nto*)
    AC_DEFINE(XP_UNIX)
    AC_DEFINE(NTO)
    AC_DEFINE(_QNX_SOURCE)
    AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
    MKSHLIB='$(CC) $(DSO_LDOPTS) -Wl,-soname -Wl,$(notdir $@) -o $@'
    DSO_CFLAGS=-fPIC
    DSO_LDOPTS=-shared
    OS_LIBS="$OS_LIBS -lsocket"
    _OPTIMIZE_FLAGS="-O1"
    _DEBUG_FLAGS="-gstabs"
	;;

*-openbsd*)
    LD='$(CC)'
    AC_DEFINE(XP_UNIX)
    AC_DEFINE(OPENBSD)
    AC_DEFINE(HAVE_BSD_FLOCK)
    AC_DEFINE(HAVE_SOCKLEN_T)
    CFLAGS="$CFLAGS -ansi -Wall"
    CXXFLAGS="$CXXFLAGS -ansi -Wall"
    if test "$SO_VERSION"; then
        DLL_SUFFIX="so.$SO_VERSION"
    else
        DLL_SUFFIX=so.1.0
    fi
    DSO_CFLAGS=-fPIC
    USE_NSPR_THREADS=1
    DSO_LDOPTS='-shared -fPIC'
    ;;

*-openvms*)
    AC_DEFINE(XP_UNIX)
    RESOLVE_LINK_SYMBOLS=1
    AR_FLAGS='c $@'
    DSO_LDOPTS='-shared -auto_symvec $(LDFLAGS) $(OPTIMIZER)'
    ;;

*-os2*)
    AC_DEFINE(OS2)
    AC_DEFINE(XP_OS2)
    AC_DEFINE(XP_PC)
#    AC_DEFINE(USE_OS2_TOOLKIT_HEADERS)
    AC_DEFINE(TCPV40HDRS)
    AC_DEFINE(BSD_SELECT)
    AC_DEFINE(_PR_GLOBAL_THREADS_ONLY)
    RESOLVE_LINK_SYMBOLS=1
    NSINSTALL=nsinstall
    LIB_PREFIX=
    LIB_SUFFIX=lib
    DLL_SUFFIX=dll
    DLLTOOL=''
    RC=rc.exe
    PROG_SUFFIX=.exe
    AR=emxomfar
    AR_FLAGS='r $@'
    LD='$(CC)'
    CFLAGS="$CFLAGS -Wall -Zomf"
    CXXFLAGS="$CFLAGS -Wall -Zomf"
    MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
    DSO_CFLAGS=
    DSO_LDOPTS='-Zomf -Zdll'
    _OPTIMIZE_FLAGS=-O3
    _DEBUG_FLAGS="-g -fno-inline"
    if test -n "$MOZ_OPTIMIZE"; then
        DSO_LDOPTS="$DSO_LDOPTS -Zlinker /EXEPACK:2 -Zlinker /PACKCODE -Zlinker /PACKDATA"
    fi
    OS_LIBS="-lsocket"
    IMPLIB='emximp -o'
    FILTER='emxexp -o'
    if test -n "$MOZ_OS2_HIGH_MEMORY"; then
        DSO_LDOPTS="$DSO_LDOPTS -Zhigh-mem"
        LDFLAGS="$LDFLAGS -Zhigh-mem"
        AC_DEFINE(MOZ_OS2_HIGH_MEMORY)
    fi

    # GCC for OS/2 currently predefines these, but we don't want them
    DEFINES="$DEFINES -Uunix -U__unix -U__unix__"
    ;;

*-osf*)
    SHELL_OVERRIDE="SHELL		= /usr/bin/ksh"
    AC_DEFINE(XP_UNIX)
    AC_DEFINE(OSF1)
    AC_DEFINE(_REENTRANT)
    AC_CHECK_HEADER(machine/builtins.h, AC_DEFINE(OSF1_HAVE_MACHINE_BUILTINS_H))

    if echo "$OS_RELEASE" | egrep -c '(V2.0|V3.2)' 2>/dev/null ; then
        USE_NSPR_THREADS=1
    fi

    if test -z "$GNU_CC"; then
        CC="$CC -std1 -ieee_with_inexact"
        if test "$OS_RELEASE" != "V2.0"; then
            CC="$CC -readonly_strings"
        fi
        _OPTIMIZE_FLAGS="$_OPTIMIZE_FLAGS -Olimit 4000"
    fi

    if echo $OS_RELEASE | egrep -c '(V2.0|V3.2)' 2>/dev/null; then
        AC_DEFINE(HAVE_INT_LOCALTIME_R)
    else
        AC_DEFINE(HAVE_FCNTL_FILE_LOCKING)
        AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
    fi
    if echo $OS_RELEASE | grep -c V4.0 >/dev/null; then
        AC_DEFINE(OSF1V4_MAP_PRIVATE_BUG)
    fi
    DSO_LDOPTS='-shared -all -expect_unresolved "*" -soname $(notdir $@)'
    ;;

*-qnx*)
    AC_DEFINE(XP_UNIX)
    AC_DEFINE(QNX)
    AC_DEFINE(_PR_NEED_H_ERRNO)
    USE_NSPR_THREADS=1
    ;;

*-*-sco*)
    AC_DEFINE(XP_UNIX)
    AC_DEFINE(SCO)
    AC_DEFINE(sco)
    AC_DEFINE(SYSV)
    AC_DEFINE(_SVID3)
    AC_DEFINE(_PR_NEED_H_ERRNO)
    CC='cc -b elf -KPIC'
    CXX='$(NSDEPTH)/build/hcpp CC +.cpp +w'
    USE_NSPR_THREADS=1
    CPU_ARCH=x86
    DSO_LDOPTS='-b elf -G'
    ;;

*-sinix*)
    AC_DEFINE(XP_UNIX)
    AC_DEFINE(SVR4)
    AC_DEFINE(SNI)
    AC_DEFINE(RELIANTUNIX)
    AC_DEFINE(sinix)
    AC_DEFINE(HAVE_SVID_GETTOD)
    if echo "$OS_TEST" | grep -c 86 2>/dev/null; then
        AC_DEFINE(i386)
        CPU_ARCH=x86
    else
        CPU_ARCH=mips
    fi

    if test "$GNU_CC"; then
        AS='$(CC) -x assembler-with-cpp'
        if test "$CPU_ARCH" = "mips"; then
            LD=gld
        fi
        CFLAGS="$CFLAGS -Wall -Wno-format"
    else
        AS='/usr/bin/cc'
        _OPTIMIZE_FLAGS='-O -F Olimit,4000'
    fi

    DSO_LDOPTS='-G -z defs -h $(@:$(OBJDIR)/%.so=%.so)'

    if test "$OS_RELEASE" = "5.43"; then
        AC_DEFINE(IP_MULTICAST)
    fi

    OS_LIBS="$OS_LIBS -lsocket -lnsl -lresolv -ldl -lc"
    USE_NSPR_THREADS=1
    ;;

*-sunos*)
    AC_DEFINE(XP_UNIX)
    AC_DEFINE(SUNOS4)
    CFLAGS="$CFLAGS -Wall -Wno-format"
    if test "$USE_MDUPDATE"; then
        CFLAGS="$CFLAGS -MDupdate \$(DEPENDENCIES)"
    fi
    CPU_ARCH=sparc
    DLL_SUFFIX=so.1.0
    DSO_LDOPTS=
    DSO_CFLAGS=-fPIC
    USE_NSPR_THREADS=1
    if test "$OS_RELEASE" = "4.1.3_U1"; then
        _OPTIMIZE_FLAGS=
        OS_LIBS="$OS_LIBS -lm"
    fi
    ;;

*-solaris*)
    if test -z "$USE_USER_THREADS" && test -z "$USE_NATIVE_THREADS"; then
        USE_PTHREADS=1
    fi
    AC_DEFINE(XP_UNIX)
    AC_DEFINE(SVR4)
    AC_DEFINE(SYSV)
    AC_DEFINE(__svr4)
    AC_DEFINE(__svr4__)
    AC_DEFINE(SOLARIS)
    AC_DEFINE(HAVE_FCNTL_FILE_LOCKING)
    if test -n "$GNU_CC" ; then
        if test -n "$USE_64"; then
            CC="$CC -m64"
            CXX="$CXX -m64"
        fi
        LD='$(CC)'
        DSO_LDOPTS='-shared -Wl,-soname -Wl,$(notdir $@)'
        DSO_CFLAGS=-fPIC
        CFLAGS="$CFLAGS -Wall"
        CXXFLAGS="$CXXFLAGS -Wall"
        if test -n "$USE_MDUPDATE"; then
            CFLAGS="$CFLAGS -MDupdate \$(DEPENDENCIES)"
            CXXFLAGS="$CXXFLAGS -MDupdate \$(DEPENDENCIES)"
        fi
    else
        LD=/usr/ccs/bin/ld
        RANLIB=/usr/ccs/bin/ranlib
    	DSO_LDOPTS='-G -h $(notdir $@)'
        DSO_CFLAGS=-KPIC
    	if test -n "$USE_64"; then
    		if test "$OS_TEST" = "i86pc"; then
    			CC="$CC -xarch=amd64"
            	CXX="$CXX -xarch=amd64"
            else
            	CC="$CC -xarch=v9"
            	CXX="$CXX -xarch=v9"
            fi
        fi
        CC="$CC -xstrconst"
        if test -z "$MOZ_OPTIMIZE"; then
            CFLAGS="$CFLAGS -xs"
            CXXFLAGS="$CXXFLAGS -xs"
        fi
    fi
    if test "$DEFAULT_RPATHFLAG" = "$RPATHFLAG" ; then
       # add origin stuff
       RPATHFLAG="\\\$\$ORIGIN/../lib:\\\$\$ORIGIN/../../lib:$RPATHFLAG"
    fi
    if test -z "$GNU_AS"; then
        ASFLAGS="$ASFLAGS -Wa,-P"
    fi
    if test "$OS_TEST" = "i86pc"; then
        AC_DEFINE(i386)

        # The default debug format, DWARF (-g), is not supported by gcc
        # on i386-ANY-sysv4/solaris, but the stabs format is.  It is
        # assumed that the Solaris assembler /usr/ccs/bin/as is used.
        # If your gcc uses GNU as, you do not need the -Wa,-s option.
        if test -n "$MOZ_DEBUG" && test -n "$GNU_CC"; then
            _DEBUG_FLAGS=-gstabs
            if test -z "$GNU_AS"; then
                _DEBUG_FLAGS="$_DEBUG_FLAGS -Wa,-s"
            fi
        fi
    fi
    case "${target_os}" in
    solaris2.3*)
        AC_DEFINE(_PR_NO_LARGE_FILES)
        ;;
    solaris2.4*)
        AC_DEFINE(_PR_NO_LARGE_FILES)
        ;;
    solaris2.5*)
        AC_DEFINE(SOLARIS2_5)    
        ;;
    *)
        AC_DEFINE(_PR_HAVE_OFF64_T)
        # The lfcompile64(5) man page on Solaris 2.6 says:
        #     For applications that do not wish to conform to the POSIX or
        #     X/Open  specifications,  the  64-bit transitional interfaces
        #     are available by default.  No compile-time flags need to  be
        #     set.
        # But gcc 2.7.2.x fails to define _LARGEFILE64_SOURCE by default.
        # The native compiler, gcc 2.8.x, and egcs don't have this problem.
        if test -n "$GNU_CC"; then
            AC_DEFINE(_LARGEFILE64_SOURCE)
        fi
        ;;
    esac
    if test "$OS_TEST" = "sun4u"; then
        # 64-bit Solaris requires SPARC V9 architecture, so the following
        # is not needed.
        if test -z "$USE_64"; then
            ULTRASPARC_LIBRARY=ultrasparc
            ULTRASPARC_FILTER_LIBRARY=libatomic.so
            DSO_LDOPTS="$DSO_LDOPTS -f "'$(ULTRASPARC_FILTER_LIBRARY)'
        fi
    fi
    ;;

*-sco-sysv5*)
    AC_DEFINE(XP_UNIX)
    AC_DEFINE(UNIXWARE)
    AC_DEFINE(SVR4)
    AC_DEFINE(SYSV)
    USE_NSPR_THREADS=1
    if echo $OS_RELEASE | grep -c 2.1 2>/dev/null; then
        AC_DEFINE(_PR_NO_LARGE_FILES)
        CC='$(NSDEPTH)/build/hcc cc'
        CXX='$(NSDEPTH)/build/hcpp CC'
    else
        AC_DEFINE(_LARGEFILE64_SOURCE)
        AC_DEFINE(_PR_HAVE_OFF64_T)
        AC_DEFINE(_PR_HAVE_SOCKADDR_LEN)
    fi
    DSO_LDOPTS=-G
    CPU_ARCH=x86
    ;;

*)
    AC_DEFINE(XP_UNIX)
    ;;
   
esac

if test -z "$SKIP_LIBRARY_CHECKS"; then
dnl ========================================================
dnl Check for system libraries
dnl ========================================================
dnl AC_CHECK_LIB(C, main)
dnl AC_CHECK_LIB(C_r, main)
dnl AC_CHECK_LIB(c, main)
dnl AC_CHECK_LIB(c_r, main)
dnl AC_CHECK_LIB(dce, main)
dnl AC_CHECK_LIB(dl, main)
dnl AC_CHECK_LIB(dld, main)
dnl AC_CHECK_LIB(gen, main)
dnl AC_CHECK_LIB(ip6, main)
dnl AC_CHECK_LIB(l, main)
dnl AC_CHECK_LIB(m, main)
dnl AC_CHECK_LIB(nsl, main)
dnl AC_CHECK_LIB(posix4, main)
dnl AC_CHECK_LIB(prstrms, main)
dnl AC_CHECK_LIB(prstrms_shr, main)
dnl AC_CHECK_LIB(pthread, main)
dnl AC_CHECK_LIB(pthreads, main)
dnl AC_CHECK_LIB(resolv, main)
dnl AC_CHECK_LIB(rt, main)
dnl AC_CHECK_LIB(socket, main)
dnl AC_CHECK_LIB(svld, main)
dnl AC_CHECK_LIB(thread, main)
dnl AC_CHECK_LIB(vms_jackets, main)

AC_CHECK_FUNC(dlopen,,[
    AC_CHECK_LIB(dl, dlopen, [OS_LIBS="-ldl $OS_LIBS"])
])

dnl ========================================================
dnl Check for system header files.
dnl ========================================================
dnl AC_HEADER_DIRENT
dnl AC_HEADER_STDC
dnl AC_HEADER_SYS_WAIT
dnl AC_CHECK_HEADERS(fcntl.h limits.h sys/file.h sys/ioctl.h sys/time.h unistd.h)

dnl ========================================================
dnl Check for typedefs and structs
dnl ========================================================
dnl AC_C_CONST
dnl AC_TYPE_UID_T
dnl AC_TYPE_MODE_T
dnl AC_TYPE_OFF_T
dnl AC_TYPE_PID_T
dnl AC_TYPE_SIZE_T
dnl AC_STRUCT_ST_BLKSIZE
dnl AC_STRUCT_ST_BLOCKS
dnl AC_STRUCT_ST_RDEV
dnl AC_HEADER_TIME
dnl AC_STRUCT_TM

dnl ========================================================
dnl Checks for library functions.
dnl ========================================================
AC_PROG_GCC_TRADITIONAL
AC_CHECK_FUNCS(lchown strerror getaddrinfo getnameinfo)

dnl AC_FUNC_MEMCMP
dnl AC_FUNC_MMAP
dnl AC_FUNC_SETVBUF_REVERSED
dnl AC_FUNC_STRCOLL
dnl AC_FUNC_STRFTIME
dnl AC_FUNC_UTIME_NULL
dnl AC_FUNC_VPRINTF
dnl AC_CHECK_FUNCS(ftime getcwd gethostname gettimeofday getwd mkdir mktime putenv rmdir select socket strdup strerror strstr strtol strtoul uname)

dnl ========================================================
dnl Check options
dnl ========================================================

dnl ========================================================
dnl =
dnl = --enable-strip
dnl = 
dnl = Enable stripping of libs and executables
dnl = 
dnl ========================================================
AC_ARG_ENABLE(strip,
[  --enable-strip          Enable stripping of shared libs and programs],
  [ ENABLE_STRIP=1 ])

dnl
dnl Apparently, some systems cannot properly check for the pthread
dnl library unless <pthread.h> is included so we need to test
dnl using it
dnl
dnl MOZ_CHECK_PTHREADS(lib, success, failure)
AC_DEFUN(MOZ_CHECK_PTHREADS,
[
AC_MSG_CHECKING([for pthread_create in -l$1])
echo "
    #include <pthread.h> 
    void *foo(void *v) { int a = 1;  } 
    int main() { 
        pthread_t t;
        if (!pthread_create(&t, 0, &foo, 0)) {
            pthread_join(t, 0);
        }
        exit(0);
    }" > dummy.c ;
    echo "${CC-cc} -o dummy${ac_exeext} dummy.c $CFLAGS $CPPFLAGS -l[$1] $LDFLAGS $LIBS" 1>&5;
    ${CC-cc} -o dummy${ac_exeext} dummy.c $CFLAGS $CPPFLAGS -l[$1] $LDFLAGS $LIBS 2>&5;
    _res=$? ;
    rm -f dummy.c dummy${ac_exeext} ;
    if test "$_res" = "0"; then
        AC_MSG_RESULT([yes])
        [$2]
    else
        AC_MSG_RESULT([no])
        [$3]
    fi
])

MOZ_CHECK_PTHREADS(pthreads,
    _HAVE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthreads",
    MOZ_CHECK_PTHREADS(pthread,
        _HAVE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthread",
        MOZ_CHECK_PTHREADS(c_r,
            _HAVE_PTHREADS=1 _PTHREAD_LDFLAGS="-lc_r",
            MOZ_CHECK_PTHREADS(c,
                _HAVE_PTHREADS=1
            )
        )
    )
)
                        
AC_ARG_WITH(pthreads,
    [  --with-pthreads         Use system pthreads library as thread subsystem],
    [ if test "$withval" = "yes"; then
	    if test -n "$_HAVE_PTHREADS"; then
		    USE_PTHREADS=1 
		    USE_USER_PTHREADS=
		    USE_NSPR_THREADS=
	    else
		    AC_MSG_ERROR([ --with-pthreads specified for a system without pthread support ]);
	    fi
	  else
	    USE_PTHREADS=
	    _PTHREAD_LDFLAGS=
	  fi],
	[ if test -n "$_HAVE_PTHREADS" && test -z "$USE_USER_PTHREADS" && test -z "$USER_NSPR_THREADS"; then
	    USE_PTHREADS=1
	    USE_USER_PTHREADS=
	    USE_NSPR_THREADS=
	  fi])

AC_ARG_ENABLE(user-pthreads,
    [  --enable-user-pthreads  Build using userland pthreads],
    [ if test "$enableval" = "yes"; then
        if test -n "$_HAVE_PTHREADS"; then
		    USE_PTHREADS=
		    USE_USER_PTHREADS=1
		    USE_NSPR_THREADS=
	    else
		    AC_MSG_ERROR([ --enable-user-pthreads specified for a system without pthread support ]);
	    fi
	  fi])

AC_ARG_ENABLE(nspr-threads,
    [  --enable-nspr-threads   Build using classic nspr threads],
    [ if test "$enableval" = "yes"; then
	    USE_PTHREADS=
	    USE_USER_PTHREADS=
	    USE_NSPR_THREADS=1
	  fi])

case "$target" in
*-beos*)
    AC_ARG_WITH(bthreads,
    [  --with-bthreads         Use system bthreads library as thread subsystem (BeOS only)],
    [	if test "$withval" = "yes"; then
    	    USE_BTHREADS=1
	        USE_USER_PTHREADS=
	        USE_PTHREADS=
	    fi])
    ;;

*-solaris*)
    AC_ARG_WITH(native-threads,
    [  --with-native-threads   Use native system threads as thread subsystem (Solaris only)],
    [ if test "$withval" = "yes"; then
	    USE_NATIVE_THREADS=1
	    USE_USER_PTHREADS=
	    USE_PTHREADS=
	  fi])
    ;;
esac

fi # SKIP_LIBRARY_CHECKS

AC_ARG_ENABLE(cplus,
    [  --enable-cplus          Enable some c++ api routines],
    [ if test "$enableval" = "yes"; then
	    USE_CPLUS=1
      fi]) 

AC_ARG_ENABLE(ipv6,
    [  --enable-ipv6           Compile ipv6 support],
    [ if test "$enableval" = "yes"; then
	    USE_IPV6=1
      fi])

dnl ========================================================
dnl = check for sasl options
dnl = This has to come after we set all of the platform specific
dnl = compiler and linker flags
dnl ========================================================
AM_PATH_GIVEN_SASL()

if test -n "$USE_PTHREADS"; then
   dnl See if -pthread is supported.
   rm -f conftest*
   ac_cv_have_dash_pthread=no
   AC_MSG_CHECKING(whether ${CC-cc} accepts -pthread)
   echo 'int main() { return 0; }' | cat > conftest.c
   ${CC-cc} -pthread -o conftest conftest.c > conftest.out 2>&1
   if test $? -eq 0; then
	if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthread`" && test -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
	    ac_cv_have_dash_pthread=yes
	    CFLAGS="$CFLAGS -pthread"
	    CXXFLAGS="$CXXFLAGS -pthread"
	fi
    fi
    rm -f conftest*
    AC_MSG_RESULT($ac_cv_have_dash_pthread)

	dnl
	dnl See if -pthreads is supported.
	dnl
    ac_cv_have_dash_pthreads=no
    if test "$ac_cv_have_dash_pthread" = "no"; then
	    AC_MSG_CHECKING(whether ${CC-cc} accepts -pthreads)
    	echo 'int main() { return 0; }' | cat > conftest.c
	    ${CC-cc} -pthreads -o conftest conftest.c > conftest.out 2>&1
    	if test $? -eq 0; then
	    	if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthreads`" && test -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
			    ac_cv_have_dash_pthreads=yes
			    CFLAGS="$CFLAGS -pthreads"
			    CXXFLAGS="$CXXFLAGS -pthreads"
		    fi
	    fi
	    rm -f conftest*
    	AC_MSG_RESULT($ac_cv_have_dash_pthreads)
    fi

    case "$target" in
    *-solaris*)
        if test "$ac_cv_have_dash_pthreads" = "yes"; then
            _PTHREAD_LDFLAGS=
        fi
	    ;;
    *-freebsd*|*-openbsd*|*-bsdi*|*-netbsd*)
	    AC_DEFINE(_THREAD_SAFE)
	    dnl -pthread links in -lc_r, so don't specify it explicitly.
	    if test "$ac_cv_have_dash_pthread" = "yes"; then
	        _PTHREAD_LDFLAGS=
	    fi
	    ;;
    *-linux*)
        AC_DEFINE(_REENTRANT)
        ;;
    esac

else 
    if test -n "$USE_USER_PTHREADS"; then
	    USE_PTHREADS=
	    USE_NSPR_THREADS=
    else
        _PTHREAD_LDFLAGS=
    fi
fi
dnl Special thread exceptions

case "$target" in
*-aix*)
    if test -n "$USE_NSPR_THREADS"; then
        AC_DEFINE(_PR_LOCAL_THREADS_ONLY)
    fi
    case "$target_os" in
    aix4.1*)
        if test -z "$USE_PTHREADS"; then
            AC_DEFINE(AIX_RENAME_SELECT)
        fi
        ;;
    aix4.2*)
        if test -z "$USE_NSPR_THREADS"; then
            AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
        fi
        ;;
    aix4.3*)
        if test -z "$USE_NSPR_THREADS"; then
            AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
        fi
        if test -n "$USE_PTHREADS"; then
            AC_DEFINE(_PR_HAVE_THREADSAFE_GETHOST)
        fi
        ;;
    esac
    ;;
*-bsdi*)
    if test -n "$USE_PTHREADS"; then
        AC_DEFINE(_PR_NEED_PTHREAD_INIT)
    fi
    ;;
*-freebsd*)
    if test -n "$USE_NSPR_THREADS"; then
        AC_DEFINE(_PR_LOCAL_THREADS_ONLY)
    fi
    ;;
*-hpux*)
    if test -n "$USE_NSPR_THREADS"; then
        AC_DEFINE(_PR_LOCAL_THREADS_ONLY)
    fi 
    if test "$USE_PTHREADS"; then
        if echo "$OS_RELEASE" | egrep '^(B.10.10|B.10.20)' >/dev/null; then
            AC_DEFINE(_REENTRANT)
            AC_DEFINE(_PR_DCETHREADS)
        else
            AC_DEFINE_UNQUOTED(_POSIX_C_SOURCE,199506L)
            AC_DEFINE(_PR_HAVE_THREADSAFE_GETHOST)
        fi
    fi
    if test "$USE_USER_PTHREADS"; then
        AC_DEFINE_UNQUOTED(_POSIX_C_SOURCE,199506L)
    fi
    ;;
*-irix*)
    if test "${target_os}" = "irix6.5"; then
        if test -n "$USE_PTHREADS"; then
            AC_DEFINE(_PR_HAVE_GETHOST_R)
            AC_DEFINE(_PR_HAVE_GETHOST_R_POINTER)
        fi
    fi
    ;;
*-linux*)
    if test -n "$USE_NSPR_THREADS"; then
        AC_DEFINE(_PR_LOCAL_THREADS_ONLY)
    fi
    ;;
*-mingw*|*-cygwin*|*-msvc*|*-mks*|*-os2*|*-beos*)
    dnl win32, os2 & beos cannot use pthreads
    USE_PTHREADS=
    _PTHREAD_LDFLAGS=
    USE_USER_PTHREADS=
    ;;
*-netbsd*)
    if test -n "$USE_NSPR_THREADS"; then
        AC_DEFINE(_PR_LOCAL_THREADS_ONLY)
    fi
    ;;
*-osf*)
    if test -n "$USE_NSPR_THREADS"; then
        AC_DEFINE(_PR_LOCAL_THREADS_ONLY)
    fi
    if test -n "$USE_PTHREADS"; then
        if echo $OS_RELEASE | egrep -c '(V2.0|V3.2)' 2>/dev/null; then
            :
        else
            AC_DEFINE(_PR_HAVE_THREADSAFE_GETHOST)
        fi
    fi
    ;;
*-solaris*)
    if test -n "$USE_NATIVE_THREADS"; then
        AC_DEFINE(_PR_GLOBAL_THREADS_ONLY)
    else
        if test -n "$USE_NSPR_THREADS"; then
            AC_DEFINE(_PR_LOCAL_THREADS_ONLY)
        fi
    fi
    if test -z "$USE_NSPR_THREADS"; then
        AC_DEFINE(_REENTRANT)
        AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
    fi
    ;;
*-nto*)
    if test -n "$USE_PTHREADS"; then
        AC_DEFINE(_PR_HAVE_GETHOST_R)
        AC_DEFINE(_PR_HAVE_GETHOST_R_POINTER)
    fi
    ;;
esac

OS_LIBS="$_PTHREAD_LDFLAGS $OS_LIBS"

dnl If the user passed in arg to --enable-optimize or --enable-debug,
dnl make sure that we use it.
if test -n "$_SAVE_OPTIMIZE_FLAGS"; then
    _OPTIMIZE_FLAGS="$_SAVE_OPTIMIZE_FLAGS"
fi

if test -n "$_SAVE_DEBUG_FLAGS"; then
    _DEBUG_FLAGS="$_SAVE_DEBUG_FLAGS"
fi

if test -n "$MOZ_OPTIMIZE"; then
    CFLAGS="$CFLAGS $_OPTIMIZE_FLAGS"
    CXXFLAGS="$CXXFLAGS $_OPTIMIZE_FLAGS"
fi

if test -n "$MOZ_DEBUG"; then
    CFLAGS="$CFLAGS $_DEBUG_FLAGS"
    CXXFLAGS="$CXXFLAGS $_DEBUG_FLAGS"
fi

dnl ========================================================
dnl Use cygwin wrapper for win32 builds, except MinGW/MSYS
dnl ========================================================
case "$target_os" in
cygwin*|msvc*|mks*)
    CC="\$(CYGWIN_WRAPPER) $CC"
    CXX="\$(CYGWIN_WRAPPER) $CXX"
    RC="\$(CYGWIN_WRAPPER) $RC"
    ;;
esac

dnl ========================================================
dnl Substitution of found variables.
dnl ========================================================
AC_SUBST(SHELL_OVERRIDE)

AC_SUBST(MOZILLA_CLIENT)
AC_SUBST(CC)
AC_SUBST(CXX)
AC_SUBST(CFLAGS)
AC_SUBST(CXXFLAGS)
AC_SUBST(CPPFLAGS)
AC_SUBST(HOST_CC)
AC_SUBST(HOST_CFLAGS)
AC_SUBST(LDFLAGS)
AC_SUBST(GNU_CC)
AC_SUBST(CROSS_COMPILE)

AC_SUBST(MOZ_OPTIMIZE)

AC_SUBST(USE_CPLUS)
AC_SUBST(USE_IPV6)
AC_SUBST(USE_N32)
AC_SUBST(USE_64)
AC_SUBST(OBJECT_MODE)
AC_SUBST(ENABLE_STRIP)

AC_SUBST(USE_PTHREADS)
AC_SUBST(USE_BTHREADS)
AC_SUBST(USE_USER_PTHREADS)
AC_SUBST(USE_NATIVE_THREADS)
AC_SUBST(USE_NSPR_THREADS)
AC_SUBST(USE_NSS)
AC_SUBST(NSS_CFLAGS)
AC_SUBST(NSS_LIBS)

AC_SUBST(CPU_ARCH)

AC_SUBST(OBJ_SUFFIX)
AC_SUBST(LIB_SUFFIX)
AC_SUBST(LIB_PREFIX)
AC_SUBST(DLL_SUFFIX)
AC_SUBST(ASM_SUFFIX)
AC_SUBST(PROG_SUFFIX)
AC_SUBST(MKSHLIB)
AC_SUBST(DSO_CFLAGS)
AC_SUBST(DSO_LDOPTS)

AC_SUBST(OS_TARGET)
AC_SUBST(OS_ARCH)
AC_SUBST(OS_RELEASE)
AC_SUBST(OS_TEST)

AC_SUBST(DEFINES)
AC_SUBST(DEFS)
AC_SUBST(AR)
AC_SUBST(AR_FLAGS)
AC_SUBST(AS)
AC_SUBST(ASFLAGS)
AC_SUBST(LD)
AC_SUBST(WINDRES)
AC_SUBST(RANLIB)
AC_SUBST(PERL)
AC_SUBST(STRIP)
AC_SUBST(FILTER)
AC_SUBST(IMPLIB)

AC_SUBST(OS_LIBS)
AC_SUBST(RESOLVE_LINK_SYMBOLS)
AC_SUBST(NOSUCHFILE)
AC_SUBST(MOZ_OBJFORMAT)
AC_SUBST(ULTRASPARC_LIBRARY)
AC_SUBST(ULTRASPARC_FILTER_LIBRARY)

AC_SUBST(OBJDIR)
AC_SUBST(OBJDIR_NAME)
AC_SUBST(NSINSTALL)
AC_SUBST(OPTIMIZER)
AC_SUBST(RC)
AC_SUBST(DLLFLAGS)
AC_SUBST(EXEFLAGS)
AC_SUBST(OS_DLLFLAGS)
AC_SUBST(CYGWIN_WRAPPER)
AC_SUBST(WIN_TOP_SRC)
AC_SUBST(NEXT_ROOT)
AC_SUBST(RPATHFLAG)

AC_SUBST(MFLAGS)

dnl ========================================================
dnl Generate output files.
dnl ========================================================
MAKEFILES="
Makefile
config/Makefile
config/autoconf.mk
ldap/Makefile
ldap/clients/tools/Makefile
ldap/include/Makefile
ldap/libraries/Makefile
ldap/libraries/libldap/Makefile
ldap/libraries/libprldap/Makefile
ldap/libraries/libldif/Makefile
ldap/libraries/liblber/Makefile
ldap/libraries/libiutil/Makefile
ldap/libraries/libssldap/Makefile
ldap/libraries/libutil/Makefile
"

dnl since configure won't handle 2 levels of directory
dnl structure for us..
mkdir ldap > /dev/null 2>&1
mkdir ldap/clients > /dev/null 2>&1

echo $MAKEFILES > unallmakefiles

AC_OUTPUT([$MAKEFILES])