fixup commit for branch 'DOUGT_CHANNEL_CHANGES_02112001_BRANCH' DOUGT_CHANNEL_CHANGES_02112001_BRANCH DOUGT_CHANNEL_CHANGES_02112001_BASE DOUGT_CHANNEL_PRELAND_02092001_1600_BASE MOZILLA_0_8_2001020916_BASE MOZILLA_0_8_20010215_RELEASE
authorcvs2hg
Fri, 09 Feb 2001 21:30:16 +0000
branchDOUGT_CHANNEL_CHANGES_02112001_BRANCH
changeset 1724 486d3df5e5b7313d6e96110be0f7d7646c1b2334
parent 1204 e4d8a15c51158af9808e53c5c3ec90954f504042
child 1725 f1fa39aa8d75ad31ed17d5d3d97c0e1e13c3ced4
child 4445 fd792513817e183bef2f604e072956a1cb34d2c7
push idunknown
push userunknown
push dateunknown
fixup commit for branch 'DOUGT_CHANNEL_CHANGES_02112001_BRANCH'
Makefile
Makefile.in
build/autoconf/config.guess
build/autoconf/config.sub
config/BSD_OS.mk
config/BeOS.mk
config/Linux.mk
config/Makefile.in
config/NTO.mk
config/NetBSD.mk
config/OS2.mk
config/OSF1.mk
config/OpenBSD.mk
config/Rhapsody.mk
config/UNIX.mk
config/WIN32.mk
config/arch.mk
config/autoconf.mk.in
config/config.mk
config/nsinstall.c
config/rules.mk
config/win16.mk
configure
configure.in
lib/Makefile
lib/Makefile.in
lib/ds/Makefile
lib/ds/Makefile.in
lib/ds/plhash.c
lib/ds/plhash.h
lib/libc/Makefile
lib/libc/Makefile.in
lib/libc/include/Makefile
lib/libc/include/Makefile.in
lib/libc/src/Makefile
lib/libc/src/Makefile.in
lib/libc/src/strccmp.c
lib/msgc/Makefile
lib/msgc/Makefile.in
lib/msgc/include/Makefile
lib/msgc/include/Makefile.in
lib/msgc/src/Makefile
lib/msgc/src/Makefile.in
lib/msgc/tests/Makefile
lib/msgc/tests/Makefile.in
lib/prstreams/Makefile
lib/prstreams/Makefile.in
lib/prstreams/tests/testprstrm/Makefile
lib/prstreams/tests/testprstrm/Makefile.in
lib/tests/Makefile
lib/tests/Makefile.in
macbuild/NSPR20PPC.mcp
macbuild/NSPRConfig.h
pr/include/Makefile
pr/include/Makefile.in
pr/include/md/Makefile
pr/include/md/Makefile.in
pr/include/md/_aix32in6.cfg
pr/include/md/_aix64.cfg
pr/include/md/_beos.cfg
pr/include/md/_beos.h
pr/include/md/_bsdi.cfg
pr/include/md/_darwin.cfg
pr/include/md/_darwin.h
pr/include/md/_freebsd.cfg
pr/include/md/_linux.cfg
pr/include/md/_linux.h
pr/include/md/_macos.h
pr/include/md/_netbsd.cfg
pr/include/md/_netbsd.h
pr/include/md/_nto.cfg
pr/include/md/_nto.h
pr/include/md/_openbsd.cfg
pr/include/md/_openvms.cfg
pr/include/md/_openvms.h
pr/include/md/_os2.cfg
pr/include/md/_pth.h
pr/include/md/_rhapsody.cfg
pr/include/md/_rhapsody.h
pr/include/md/_solaris.h
pr/include/obsolete/Makefile
pr/include/obsolete/Makefile.in
pr/include/obsolete/protypes.h
pr/include/prinit.h
pr/include/prio.h
pr/include/private/Makefile
pr/include/private/Makefile.in
pr/include/private/primpl.h
pr/include/prtypes.h
pr/src/Makefile
pr/src/Makefile.in
pr/src/bthreads/Makefile
pr/src/bthreads/Makefile.in
pr/src/bthreads/btcvar.c
pr/src/bthreads/btthread.c
pr/src/cplus/Makefile
pr/src/cplus/Makefile.in
pr/src/cplus/tests/Makefile
pr/src/cplus/tests/Makefile.in
pr/src/io/Makefile
pr/src/io/Makefile.in
pr/src/io/pripv6.c
pr/src/io/prlog.c
pr/src/io/prprf.c
pr/src/io/prsocket.c
pr/src/linking/Makefile
pr/src/linking/Makefile.in
pr/src/linking/prlink.c
pr/src/malloc/Makefile
pr/src/malloc/Makefile.in
pr/src/md/Makefile
pr/src/md/Makefile.in
pr/src/md/beos/Makefile
pr/src/md/beos/Makefile.in
pr/src/md/mac/macdll.c
pr/src/md/mac/macsockotpt.c
pr/src/md/mac/mdmac.c
pr/src/md/mac/prcpucfg.h
pr/src/md/os2/Makefile
pr/src/md/os2/Makefile.in
pr/src/md/os2/os2io.c
pr/src/md/unix/Makefile
pr/src/md/unix/Makefile.in
pr/src/md/unix/darwin.c
pr/src/md/unix/objs.mk
pr/src/md/unix/os_Linux_x86.s
pr/src/md/unix/rhapsody.c
pr/src/md/unix/uxproces.c
pr/src/md/unix/uxrng.c
pr/src/md/unix/uxshm.c
pr/src/md/windows/Makefile
pr/src/md/windows/Makefile.in
pr/src/md/windows/ntinrval.c
pr/src/md/windows/ntio.c
pr/src/md/windows/objs.mk
pr/src/md/windows/w95io.c
pr/src/memory/Makefile
pr/src/memory/Makefile.in
pr/src/memory/prgcleak.c
pr/src/misc/Makefile
pr/src/misc/Makefile.in
pr/src/misc/prnetdb.c
pr/src/misc/prthinfo.c
pr/src/misc/prtime.c
pr/src/pthreads/Makefile
pr/src/pthreads/Makefile.in
pr/src/pthreads/ptio.c
pr/src/pthreads/ptsynch.c
pr/src/pthreads/ptthread.c
pr/src/threads/Makefile
pr/src/threads/Makefile.in
pr/src/threads/combined/Makefile
pr/src/threads/combined/Makefile.in
pr/src/threads/combined/pruthr.c
pr/tests/Makefile
pr/tests/Makefile.in
pr/tests/attach.c
pr/tests/dll/Makefile
pr/tests/dll/Makefile.in
pr/tests/ipv6.c
pr/tests/tpd.c
pr/tests/w16gui/Makefile
pr/tests/w16gui/Makefile.in
tools/Makefile
tools/Makefile.in
--- a/Makefile
+++ b/Makefile
@@ -34,21 +34,26 @@ include $(MOD_DEPTH)/config/rules.mk
 ifeq ($(OS_ARCH),WINNT)
 ZIP_ASCII_OPT = -ll
 endif
 
 ifdef PR_CLIENT_BUILD
 export::
 	rm -r -f $(DIST)/../public/nspr
 ifdef PR_CLIENT_BUILD_UNIX
-	rm -f $(DIST)/lib/libnspr.a
-	rm -f $(DIST)/bin/libnspr.$(DLL_SUFFIX)
+	rm -f $(libdir)/libnspr.a
+	rm -f $(bindir)/libnspr.$(DLL_SUFFIX)
 endif
 endif
 
+distclean::
+	@echo "cd pr/tests; $(MAKE) $@"
+	@$(MAKE) -C pr/tests $@
+	rm -f config/my_config.mk config/my_overrides.mk
+
 release::
 	echo $(BUILD_NUMBER) > $(RELEASE_DIR)/$(BUILD_NUMBER)/version.df
 	@if test -f imports.df; then \
 	    echo "cp -f imports.df $(RELEASE_DIR)/$(BUILD_NUMBER)/imports.df"; \
 	    cp -f imports.df $(RELEASE_DIR)/$(BUILD_NUMBER)/imports.df; \
 	else \
 	    echo "echo > $(RELEASE_DIR)/$(BUILD_NUMBER)/imports.df"; \
 	    echo > $(RELEASE_DIR)/$(BUILD_NUMBER)/imports.df; \
--- a/Makefile.in
+++ b/Makefile.in
@@ -26,34 +26,51 @@ include $(MOD_DEPTH)/config/autoconf.mk
 
 DIRS = config pr lib
 
 ifdef MOZILLA_CLIENT
 PR_CLIENT_BUILD = 1
 PR_CLIENT_BUILD_UNIX = 1
 endif
 
+DIST_GARBAGE = config.cache config.log config.status
+
+all:: config.status export
+
 include $(topsrcdir)/config/rules.mk
 
+config.status:: configure
+ifeq ($(OS_ARCH),WINNT)
+	sh $(srcdir)/configure --no-create --no-recursion
+else
+	./config.status --recheck && ./config.status
+endif
+
 #
 # The -ll option of zip converts CR LF to LF.
 #
 ifeq ($(OS_ARCH),WINNT)
 ZIP_ASCII_OPT = -ll
 endif
 
 ifdef PR_CLIENT_BUILD
 export::
 	rm -r -f $(DIST)/../public/nspr
 ifdef PR_CLIENT_BUILD_UNIX
-	rm -f $(DIST)/lib/libnspr.a
-	rm -f $(DIST)/bin/libnspr.$(DLL_SUFFIX)
+	rm -f $(libdir)/libnspr.a
+	rm -f $(bindir)/libnspr.$(DLL_SUFFIX)
 endif
 endif
 
+# Delete config/autoconf.mk last because it is included by every makefile.
+distclean::
+	@echo "cd pr/tests; $(MAKE) $@"
+	@$(MAKE) -C pr/tests $@
+	rm -f config/autoconf.mk
+
 release::
 	echo $(BUILD_NUMBER) > $(RELEASE_DIR)/$(BUILD_NUMBER)/version.df
 	@if test -f imports.df; then \
 	    echo "cp -f imports.df $(RELEASE_DIR)/$(BUILD_NUMBER)/imports.df"; \
 	    cp -f imports.df $(RELEASE_DIR)/$(BUILD_NUMBER)/imports.df; \
 	else \
 	    echo "echo > $(RELEASE_DIR)/$(BUILD_NUMBER)/imports.df"; \
 	    echo > $(RELEASE_DIR)/$(BUILD_NUMBER)/imports.df; \
--- a/build/autoconf/config.guess
+++ b/build/autoconf/config.guess
@@ -1,12 +1,15 @@
 #! /bin/sh
 # Attempt to guess a canonical system name.
-#   Copyright (C) 1992, 93, 94, 95, 96, 97, 1998 Free Software Foundation, Inc.
-#
+#   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
+#   Free Software Foundation, Inc.
+
+timestamp='2001-01-01'
+
 # This file is free software; you can redistribute it and/or modify it
 # under the terms of the GNU General Public License as published by
 # the Free Software Foundation; either version 2 of the License, or
 # (at your option) any later version.
 #
 # This program is distributed in the hope that it will be useful, but
 # WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
@@ -17,106 +20,243 @@
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 #
 # As a special exception to the GNU General Public License, if you
 # distribute this file as part of a program that contains a
 # configuration script generated by Autoconf, you may include it under
 # the same distribution terms that you use for the rest of that program.
 
 # Written by Per Bothner <bothner@cygnus.com>.
-# The master version of this file is at the FSF in /home/gd/gnu/lib.
+# Please send patches to <config-patches@gnu.org>.
 #
 # This script attempts to guess a canonical system name similar to
 # config.sub.  If it succeeds, it prints the system name on stdout, and
 # exits with 0.  Otherwise, it exits with 1.
 #
 # The plan is that this can be called by configure scripts if you
-# don't specify an explicit system type (host/target name).
+# don't specify an explicit build system type.
 #
 # Only a few systems have been added to this list; please add others
 # (but try to keep the structure clean).
 #
 
+me=`echo "$0" | sed -e 's,.*/,,'`
+
+usage="\
+Usage: $0 [OPTION]
+
+Output the configuration name of the system \`$me' is run on.
+
+Operation modes:
+  -h, --help         print this help, then exit
+  -t, --time-stamp   print date of last modification, then exit
+  -v, --version      print version number, then exit
+
+Report bugs and patches to <config-patches@gnu.org>."
+
+version="\
+GNU config.guess ($timestamp)
+
+Originally written by Per Bothner.
+Copyright (C) 1992, 93, 94, 95, 96, 97, 98, 99, 2000
+Free Software Foundation, Inc.
+
+This is free software; see the source for copying conditions.  There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
+
+help="
+Try \`$me --help' for more information."
+
+# Parse command line
+while test $# -gt 0 ; do
+  case $1 in
+    --time-stamp | --time* | -t )
+       echo "$timestamp" ; exit 0 ;;
+    --version | -v )
+       echo "$version" ; exit 0 ;;
+    --help | --h* | -h )
+       echo "$usage"; exit 0 ;;
+    -- )     # Stop option processing
+       shift; break ;;
+    - )	# Use stdin as input.
+       break ;;
+    -* )
+       echo "$me: invalid option $1$help" >&2
+       exit 1 ;;
+    * )
+       break ;;
+  esac
+done
+
+if test $# != 0; then
+  echo "$me: too many arguments$help" >&2
+  exit 1
+fi
+
+
+dummy=dummy-$$
+trap 'rm -f $dummy.c $dummy.o $dummy; exit 1' 1 2 15
+
+# CC_FOR_BUILD -- compiler used by this script.
+# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
+# use `HOST_CC' if defined, but it is deprecated.
+
+case $CC_FOR_BUILD,$HOST_CC,$CC in
+ ,,)    echo "int dummy(){}" > $dummy.c
+	for c in cc gcc c89 ; do
+	  ($c $dummy.c -c -o $dummy.o) >/dev/null 2>&1
+	  if test $? = 0 ; then
+	     CC_FOR_BUILD="$c"; break
+	  fi
+	done
+	rm -f $dummy.c $dummy.o
+	if test x"$CC_FOR_BUILD" = x ; then
+	  CC_FOR_BUILD=no_compiler_found
+	fi
+	;;
+ ,,*)   CC_FOR_BUILD=$CC ;;
+ ,*,*)  CC_FOR_BUILD=$HOST_CC ;;
+esac
+
 # This is needed to find uname on a Pyramid OSx when run in the BSD universe.
 # (ghazi@noc.rutgers.edu 8/24/94.)
 if (test -f /.attbin/uname) >/dev/null 2>&1 ; then
 	PATH=$PATH:/.attbin ; export PATH
 fi
 
 UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
 UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
-UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
+UNAME_SYSTEM=`(uname -s) 2>/dev/null`  || UNAME_SYSTEM=unknown
 UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
 
-trap 'rm -f dummy.c dummy.o dummy; exit 1' 1 2 15
-
 # Note: order is significant - the case branches are not exclusive.
 
 case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
+    *:NetBSD:*:*)
+	# Netbsd (nbsd) targets should (where applicable) match one or
+	# more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*,
+	# *-*-netbsdecoff* and *-*-netbsd*.  For targets that recently
+	# switched to ELF, *-*-netbsd* would select the old
+	# object file format.  This provides both forward
+	# compatibility and a consistent mechanism for selecting the
+	# object file format.
+	# Determine the machine/vendor (is the vendor relevant).
+	case "${UNAME_MACHINE}" in
+	    amiga) machine=m68k-unknown ;;
+	    arm32) machine=arm-unknown ;;
+	    atari*) machine=m68k-atari ;;
+	    sun3*) machine=m68k-sun ;;
+	    mac68k) machine=m68k-apple ;;
+	    macppc) machine=powerpc-apple ;;
+	    hp3[0-9][05]) machine=m68k-hp ;;
+	    ibmrt|romp-ibm) machine=romp-ibm ;;
+	    *) machine=${UNAME_MACHINE}-unknown ;;
+	esac
+	# The Operating System including object format, if it has switched
+	# to ELF recently, or will in the future.
+	case "${UNAME_MACHINE}" in
+	    i386|sparc|amiga|arm*|hp300|mvme68k|vax|atari|luna68k|mac68k|news68k|next68k|pc532|sun3*|x68k)
+		if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
+			| grep __ELF__ >/dev/null
+		then
+		    # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).
+		    # Return netbsd for either.  FIX?
+		    os=netbsd
+		else
+		    os=netbsdelf
+		fi
+		;;
+	    *)
+	        os=netbsd
+		;;
+	esac
+	# The OS release
+	release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
+	# Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
+	# contains redundant information, the shorter form:
+	# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
+	echo "${machine}-${os}${release}"
+	exit 0 ;;
     alpha:OSF1:*:*)
 	if test $UNAME_RELEASE = "V4.0"; then
 		UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
 	fi
 	# A Vn.n version is a released version.
 	# A Tn.n version is a released field test version.
 	# A Xn.n version is an unreleased experimental baselevel.
 	# 1.2 uses "1.2" for uname -r.
-	cat <<EOF >dummy.s
+	cat <<EOF >$dummy.s
+	.data
+\$Lformat:
+	.byte 37,100,45,37,120,10,0	# "%d-%x\n"
+
+	.text
 	.globl main
+	.align 4
 	.ent main
 main:
-	.frame \$30,0,\$26,0
-	.prologue 0
-	.long 0x47e03d80 # implver $0
-	lda \$2,259
-	.long 0x47e20c21 # amask $2,$1
-	srl \$1,8,\$2
-	sll \$2,2,\$2
-	sll \$0,3,\$0
-	addl \$1,\$0,\$0
-	addl \$2,\$0,\$0
-	ret \$31,(\$26),1
+	.frame \$30,16,\$26,0
+	ldgp \$29,0(\$27)
+	.prologue 1
+	.long 0x47e03d80 # implver \$0
+	lda \$2,-1
+	.long 0x47e20c21 # amask \$2,\$1
+	lda \$16,\$Lformat
+	mov \$0,\$17
+	not \$1,\$18
+	jsr \$26,printf
+	ldgp \$29,0(\$26)
+	mov 0,\$16
+	jsr \$26,exit
 	.end main
 EOF
-	${CC-cc} dummy.s -o dummy 2>/dev/null
+	$CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null
 	if test "$?" = 0 ; then
-		./dummy
-		case "$?" in
-			7)
+		case `./$dummy` in
+			0-0)
 				UNAME_MACHINE="alpha"
 				;;
-			15)
+			1-0)
 				UNAME_MACHINE="alphaev5"
 				;;
-			14)
+			1-1)
 				UNAME_MACHINE="alphaev56"
 				;;
-			10)
+			1-101)
 				UNAME_MACHINE="alphapca56"
 				;;
-			16)
+			2-303)
 				UNAME_MACHINE="alphaev6"
 				;;
+			2-307)
+				UNAME_MACHINE="alphaev67"
+				;;
 		esac
 	fi
-	rm -f dummy.s dummy
-	echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr [[A-Z]] [[a-z]]`
+	rm -f $dummy.s $dummy
+	echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+	exit 0 ;;
+    Alpha\ *:Windows_NT*:*)
+	# How do we know it's Interix rather than the generic POSIX subsystem?
+	# Should we change UNAME_MACHINE based on the output of uname instead
+	# of the specific Alpha model?
+	echo alpha-pc-interix
 	exit 0 ;;
     21064:Windows_NT:50:3)
 	echo alpha-dec-winnt3.5
 	exit 0 ;;
     Amiga*:UNIX_System_V:4.0:*)
-	echo m68k-cbm-sysv4
+	echo m68k-unknown-sysv4
 	exit 0;;
-    amiga:NetBSD:*:*)
-      echo m68k-cbm-netbsd${UNAME_RELEASE}
-      exit 0 ;;
     amiga:OpenBSD:*:*)
 	echo m68k-unknown-openbsd${UNAME_RELEASE}
 	exit 0 ;;
+    *:[Aa]miga[Oo][Ss]:*:*)
+	echo ${UNAME_MACHINE}-unknown-amigaos
+	exit 0 ;;
     arc64:OpenBSD:*:*)
 	echo mips64el-unknown-openbsd${UNAME_RELEASE}
 	exit 0 ;;
     arc:OpenBSD:*:*)
 	echo mipsel-unknown-openbsd${UNAME_RELEASE}
 	exit 0 ;;
     hkmips:OpenBSD:*:*)
 	echo mips-unknown-openbsd${UNAME_RELEASE}
@@ -125,36 +265,39 @@ EOF
 	echo mipsel-unknown-openbsd${UNAME_RELEASE}
 	exit 0 ;;
     sgi:OpenBSD:*:*)
 	echo mips-unknown-openbsd${UNAME_RELEASE}
 	exit 0 ;;
     wgrisc:OpenBSD:*:*)
 	echo mipsel-unknown-openbsd${UNAME_RELEASE}
 	exit 0 ;;
+    *:OS/390:*:*)
+	echo i370-ibm-openedition
+	exit 0 ;;
     arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
 	echo arm-acorn-riscix${UNAME_RELEASE}
 	exit 0;;
-    arm32:NetBSD:*:*)
-	echo arm-unknown-netbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
-	exit 0 ;;
     SR2?01:HI-UX/MPP:*:*)
 	echo hppa1.1-hitachi-hiuxmpp
 	exit 0;;
-    Pyramid*:OSx*:*:*|MIS*:OSx*:*:*)
+    Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
 	# akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
 	if test "`(/bin/universe) 2>/dev/null`" = att ; then
 		echo pyramid-pyramid-sysv3
 	else
 		echo pyramid-pyramid-bsd
 	fi
 	exit 0 ;;
-    NILE:*:*:dcosx)
+    NILE*:*:*:dcosx)
 	echo pyramid-pyramid-svr4
 	exit 0 ;;
+    sun4H:SunOS:5.*:*)
+	echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+	exit 0 ;;
     sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
 	echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
 	exit 0 ;;
     i86pc:SunOS:5.*:*)
 	echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
 	exit 0 ;;
     sun4*:SunOS:6*:*)
 	# According to config.sub, this is the proper way to canonicalize
@@ -184,31 +327,48 @@ EOF
 	    sun4)
 		echo sparc-sun-sunos${UNAME_RELEASE}
 		;;
 	esac
 	exit 0 ;;
     aushp:SunOS:*:*)
 	echo sparc-auspex-sunos${UNAME_RELEASE}
 	exit 0 ;;
-    atari*:NetBSD:*:*)
-	echo m68k-atari-netbsd${UNAME_RELEASE}
-	exit 0 ;;
     atari*:OpenBSD:*:*)
 	echo m68k-unknown-openbsd${UNAME_RELEASE}
 	exit 0 ;;
-    sun3*:NetBSD:*:*)
-	echo m68k-sun-netbsd${UNAME_RELEASE}
+    # The situation for MiNT is a little confusing.  The machine name
+    # can be virtually everything (everything which is not
+    # "atarist" or "atariste" at least should have a processor
+    # > m68000).  The system name ranges from "MiNT" over "FreeMiNT"
+    # to the lowercase version "mint" (or "freemint").  Finally
+    # the system name "TOS" denotes a system which is actually not
+    # MiNT.  But MiNT is downward compatible to TOS, so this should
+    # be no problem.
+    atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
+        echo m68k-atari-mint${UNAME_RELEASE}
 	exit 0 ;;
+    atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
+	echo m68k-atari-mint${UNAME_RELEASE}
+        exit 0 ;;
+    *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
+        echo m68k-atari-mint${UNAME_RELEASE}
+	exit 0 ;;
+    milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
+        echo m68k-milan-mint${UNAME_RELEASE}
+        exit 0 ;;
+    hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
+        echo m68k-hades-mint${UNAME_RELEASE}
+        exit 0 ;;
+    *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
+        echo m68k-unknown-mint${UNAME_RELEASE}
+        exit 0 ;;
     sun3*:OpenBSD:*:*)
 	echo m68k-unknown-openbsd${UNAME_RELEASE}
 	exit 0 ;;
-    mac68k:NetBSD:*:*)
-	echo m68k-apple-netbsd${UNAME_RELEASE}
-	exit 0 ;;
     mac68k:OpenBSD:*:*)
 	echo m68k-unknown-openbsd${UNAME_RELEASE}
 	exit 0 ;;
     mvme68k:OpenBSD:*:*)
 	echo m68k-unknown-openbsd${UNAME_RELEASE}
 	exit 0 ;;
     mvme88k:OpenBSD:*:*)
 	echo m88k-unknown-openbsd${UNAME_RELEASE}
@@ -220,40 +380,45 @@ EOF
 	echo mips-dec-mach_bsd4.3
 	exit 0 ;;
     RISC*:ULTRIX:*:*)
 	echo mips-dec-ultrix${UNAME_RELEASE}
 	exit 0 ;;
     VAX*:ULTRIX*:*:*)
 	echo vax-dec-ultrix${UNAME_RELEASE}
 	exit 0 ;;
-    2020:CLIX:*:*)
+    2020:CLIX:*:* | 2430:CLIX:*:*)
 	echo clipper-intergraph-clix${UNAME_RELEASE}
 	exit 0 ;;
     mips:*:*:UMIPS | mips:*:*:RISCos)
-	sed 's/^	//' << EOF >dummy.c
-	int main (argc, argv) int argc; char **argv; {
+	sed 's/^	//' << EOF >$dummy.c
+#ifdef __cplusplus
+#include <stdio.h>  /* for printf() prototype */
+	int main (int argc, char *argv[]) {
+#else
+	int main (argc, argv) int argc; char *argv[]; {
+#endif
 	#if defined (host_mips) && defined (MIPSEB)
 	#if defined (SYSTYPE_SYSV)
 	  printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0);
 	#endif
 	#if defined (SYSTYPE_SVR4)
 	  printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0);
 	#endif
 	#if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD)
 	  printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0);
 	#endif
 	#endif
 	  exit (-1);
 	}
 EOF
-	${CC-cc} dummy.c -o dummy \
-	  && ./dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \
-	  && rm dummy.c dummy && exit 0
-	rm -f dummy.c dummy
+	$CC_FOR_BUILD $dummy.c -o $dummy \
+	  && ./$dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \
+	  && rm $dummy.c $dummy && exit 0
+	rm -f $dummy.c $dummy
 	echo mips-mips-riscos${UNAME_RELEASE}
 	exit 0 ;;
     Night_Hawk:Power_UNIX:*:*)
 	echo powerpc-harris-powerunix
 	exit 0 ;;
     m88k:CX/UX:7*:*)
 	echo m88k-harris-cxux7
 	exit 0 ;;
@@ -261,25 +426,28 @@ EOF
 	echo m88k-motorola-sysv4
 	exit 0 ;;
     m88k:*:3*:R3*)
 	echo m88k-motorola-sysv3
 	exit 0 ;;
     AViiON:dgux:*:*)
         # DG/UX returns AViiON for all architectures
         UNAME_PROCESSOR=`/usr/bin/uname -p`
-        if [ $UNAME_PROCESSOR = mc88100 -o $UNAME_PROCESSOR = mc88110 ] ; then
-	if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx \
-	     -o ${TARGET_BINARY_INTERFACE}x = x ] ; then
+	if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ]
+	then
+	    if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \
+	       [ ${TARGET_BINARY_INTERFACE}x = x ]
+	    then
 		echo m88k-dg-dgux${UNAME_RELEASE}
+	    else
+		echo m88k-dg-dguxbcs${UNAME_RELEASE}
+	    fi
 	else
-		echo m88k-dg-dguxbcs${UNAME_RELEASE}
+	    echo i586-dg-dgux${UNAME_RELEASE}
 	fi
-        else echo i586-dg-dgux${UNAME_RELEASE}
-        fi
  	exit 0 ;;
     M88*:DolphinOS:*:*)	# DolphinOS (SVR3)
 	echo m88k-dolphin-sysv3
 	exit 0 ;;
     M88*:*:R3*:*)
 	# Delta 88k system running SVR3
 	echo m88k-motorola-sysv3
 	exit 0 ;;
@@ -295,82 +463,153 @@ EOF
     ????????:AIX?:[12].1:2)   # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
 	echo romp-ibm-aix      # uname -m gives an 8 hex-code CPU id
 	exit 0 ;;              # Note that: echo "'`uname -s`'" gives 'AIX '
     i?86:AIX:*:*)
 	echo i386-ibm-aix
 	exit 0 ;;
     *:AIX:2:3)
 	if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
-		sed 's/^		//' << EOF >dummy.c
+		sed 's/^		//' << EOF >$dummy.c
 		#include <sys/systemcfg.h>
 
 		main()
 			{
 			if (!__power_pc())
 				exit(1);
 			puts("powerpc-ibm-aix3.2.5");
 			exit(0);
 			}
 EOF
-		${CC-cc} dummy.c -o dummy && ./dummy && rm dummy.c dummy && exit 0
-		rm -f dummy.c dummy
+		$CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm $dummy.c $dummy && exit 0
+		rm -f $dummy.c $dummy
 		echo rs6000-ibm-aix3.2.5
 	elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
 		echo rs6000-ibm-aix3.2.4
 	else
 		echo rs6000-ibm-aix3.2
 	fi
 	exit 0 ;;
     *:AIX:*:4)
-	if /usr/sbin/lsattr -EHl proc0 | grep POWER >/dev/null 2>&1; then
+	IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | head -1 | awk '{ print $1 }'`
+	if /usr/sbin/lsattr -EHl ${IBM_CPU_ID} | grep POWER >/dev/null 2>&1; then
 		IBM_ARCH=rs6000
 	else
 		IBM_ARCH=powerpc
 	fi
 	if [ -x /usr/bin/oslevel ] ; then
 		IBM_REV=`/usr/bin/oslevel`
 	else
 		IBM_REV=4.${UNAME_RELEASE}
 	fi
 	echo ${IBM_ARCH}-ibm-aix${IBM_REV}
 	exit 0 ;;
+    *:AIX:*:5)
+	case "`lsattr -El proc0 -a type -F value`" in
+	    PowerPC*) IBM_ARCH=powerpc
+		      IBM_MANUF=ibm ;;
+	    Itanium)  IBM_ARCH=ia64
+		      IBM_MANUF=unknown ;;
+	    POWER*)   IBM_ARCH=power
+		      IBM_MANUF=ibm ;;
+	    *)        IBM_ARCH=powerpc
+		      IBM_MANUF=ibm ;;
+	esac
+	echo ${IBM_ARCH}-${IBM_MANUF}-aix${UNAME_VERSION}.${UNAME_RELEASE}
+	exit 0 ;;
     *:AIX:*:*)
 	echo rs6000-ibm-aix
 	exit 0 ;;
     ibmrt:4.4BSD:*|romp-ibm:BSD:*)
 	echo romp-ibm-bsd4.4
 	exit 0 ;;
-    ibmrt:*BSD:*|romp-ibm:BSD:*)            # covers RT/PC NetBSD and
+    ibmrt:*BSD:*|romp-ibm:BSD:*)            # covers RT/PC BSD and
 	echo romp-ibm-bsd${UNAME_RELEASE}   # 4.3 with uname added to
 	exit 0 ;;                           # report: romp-ibm BSD 4.3
     *:BOSX:*:*)
 	echo rs6000-bull-bosx
 	exit 0 ;;
     DPX/2?00:B.O.S.:*:*)
 	echo m68k-bull-sysv3
 	exit 0 ;;
     9000/[34]??:4.3bsd:1.*:*)
 	echo m68k-hp-bsd
 	exit 0 ;;
     hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
 	echo m68k-hp-bsd4.4
 	exit 0 ;;
-    9000/[3478]??:HP-UX:*:*)
+    9000/[34678]??:HP-UX:*:*)
+	HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
 	case "${UNAME_MACHINE}" in
 	    9000/31? )            HP_ARCH=m68000 ;;
 	    9000/[34]?? )         HP_ARCH=m68k ;;
-	    9000/7?? | 9000/8?[1679] ) HP_ARCH=hppa1.1 ;;
-	    9000/8?? )            HP_ARCH=hppa1.0 ;;
+	    9000/[678][0-9][0-9])
+              case "${HPUX_REV}" in
+                11.[0-9][0-9])
+                  if [ -x /usr/bin/getconf ]; then
+                    sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
+                    sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
+                    case "${sc_cpu_version}" in
+                      523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0
+                      528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1
+                      532)                      # CPU_PA_RISC2_0
+                        case "${sc_kernel_bits}" in
+                          32) HP_ARCH="hppa2.0n" ;;
+                          64) HP_ARCH="hppa2.0w" ;;
+                        esac ;;
+                    esac
+                  fi ;;
+              esac
+              if [ "${HP_ARCH}" = "" ]; then
+              sed 's/^              //' << EOF >$dummy.c
+
+              #define _HPUX_SOURCE
+              #include <stdlib.h>
+              #include <unistd.h>
+
+              int main ()
+              {
+              #if defined(_SC_KERNEL_BITS)
+                  long bits = sysconf(_SC_KERNEL_BITS);
+              #endif
+                  long cpu  = sysconf (_SC_CPU_VERSION);
+
+                  switch (cpu)
+              	{
+              	case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
+              	case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
+              	case CPU_PA_RISC2_0:
+              #if defined(_SC_KERNEL_BITS)
+              	    switch (bits)
+              		{
+              		case 64: puts ("hppa2.0w"); break;
+              		case 32: puts ("hppa2.0n"); break;
+              		default: puts ("hppa2.0"); break;
+              		} break;
+              #else  /* !defined(_SC_KERNEL_BITS) */
+              	    puts ("hppa2.0"); break;
+              #endif
+              	default: puts ("hppa1.0"); break;
+              	}
+                  exit (0);
+              }
+EOF
+	(CCOPTS= $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null ) && HP_ARCH=`./$dummy`
+	if test -z "$HP_ARCH"; then HP_ARCH=hppa; fi
+	rm -f $dummy.c $dummy
+	fi ;;
 	esac
-	HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
 	echo ${HP_ARCH}-hp-hpux${HPUX_REV}
 	exit 0 ;;
+    ia64:HP-UX:*:*)
+	HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
+	echo ia64-hp-hpux${HPUX_REV}
+	exit 0 ;;
     3050*:HI-UX:*:*)
-	sed 's/^	//' << EOF >dummy.c
+	sed 's/^	//' << EOF >$dummy.c
 	#include <unistd.h>
 	int
 	main ()
 	{
 	  long cpu = sysconf (_SC_CPU_VERSION);
 	  /* The order matters, because CPU_IS_HP_MC68K erroneously returns
 	     true for CPU_PA_RISC1_0.  CPU_IS_PA_RISC returns correct
 	     results, however.  */
@@ -385,42 +624,48 @@ EOF
 		}
 	    }
 	  else if (CPU_IS_HP_MC68K (cpu))
 	    puts ("m68k-hitachi-hiuxwe2");
 	  else puts ("unknown-hitachi-hiuxwe2");
 	  exit (0);
 	}
 EOF
-	${CC-cc} dummy.c -o dummy && ./dummy && rm dummy.c dummy && exit 0
-	rm -f dummy.c dummy
+	$CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm $dummy.c $dummy && exit 0
+	rm -f $dummy.c $dummy
 	echo unknown-hitachi-hiuxwe2
 	exit 0 ;;
     9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
 	echo hppa1.1-hp-bsd
 	exit 0 ;;
     9000/8??:4.3bsd:*:*)
 	echo hppa1.0-hp-bsd
 	exit 0 ;;
+    *9??*:MPE/iX:*:*)
+	echo hppa1.0-hp-mpeix
+	exit 0 ;;
     hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* )
 	echo hppa1.1-hp-osf
 	exit 0 ;;
     hp8??:OSF1:*:*)
 	echo hppa1.0-hp-osf
 	exit 0 ;;
     i?86:OSF1:*:*)
 	if [ -x /usr/sbin/sysversion ] ; then
 	    echo ${UNAME_MACHINE}-unknown-osf1mk
 	else
 	    echo ${UNAME_MACHINE}-unknown-osf1
 	fi
 	exit 0 ;;
     parisc*:Lites*:*:*)
 	echo hppa1.1-hp-lites
 	exit 0 ;;
+    hppa*:OpenBSD:*:*)
+	echo hppa-unknown-openbsd
+	exit 0 ;;
     C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
 	echo c1-convex-bsd
         exit 0 ;;
     C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
 	if getsysinfo -f scalar_acc
 	then echo c32-convex-bsd
 	else echo c2-convex-bsd
 	fi
@@ -441,230 +686,371 @@ EOF
 	echo ymp-cray-unicos${UNAME_RELEASE}
 	exit 0 ;;
     CRAY*[A-Z]90:*:*:*)
 	echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \
 	| sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
 	      -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/
 	exit 0 ;;
     CRAY*TS:*:*:*)
-	echo t90-cray-unicos${UNAME_RELEASE}
+	echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+	exit 0 ;;
+    CRAY*T3D:*:*:*)
+	echo alpha-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+	exit 0 ;;
+    CRAY*T3E:*:*:*)
+	echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+	exit 0 ;;
+    CRAY*SV1:*:*:*)
+	echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
 	exit 0 ;;
     CRAY-2:*:*:*)
 	echo cray2-cray-unicos
         exit 0 ;;
-    F300:UNIX_System_V:*:*)
-        FUJITSU_SYS=`uname -p | tr [A-Z] [a-z] | sed -e 's/\///'`
+    F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
+	FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+        FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
         FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
-        echo "f300-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
+        echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
         exit 0 ;;
-    F301:UNIX_System_V:*:*)
-       echo f301-fujitsu-uxpv`echo $UNAME_RELEASE | sed 's/ .*//'`
-       exit 0 ;;
-    hp3[0-9][05]:NetBSD:*:*)
-	echo m68k-hp-netbsd${UNAME_RELEASE}
-	exit 0 ;;
     hp300:OpenBSD:*:*)
 	echo m68k-unknown-openbsd${UNAME_RELEASE}
 	exit 0 ;;
-    i?86:BSD/386:*:* | *:BSD/OS:*:*)
+    i?86:BSD/386:*:* | i?86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
 	echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
 	exit 0 ;;
+    sparc*:BSD/OS:*:*)
+	echo sparc-unknown-bsdi${UNAME_RELEASE}
+	exit 0 ;;
+    *:BSD/OS:*:*)
+	echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
+	exit 0 ;;
     *:FreeBSD:*:*)
 	echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
 	exit 0 ;;
-    *:NetBSD:*:*)
-	echo ${UNAME_MACHINE}-unknown-netbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
-	exit 0 ;;
     *:OpenBSD:*:*)
 	echo ${UNAME_MACHINE}-unknown-openbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
 	exit 0 ;;
     i*:CYGWIN*:*)
-	echo ${UNAME_MACHINE}-pc-cygwin32
+	echo ${UNAME_MACHINE}-pc-cygwin
 	exit 0 ;;
     i*:MINGW*:*)
 	echo ${UNAME_MACHINE}-pc-mingw32
 	exit 0 ;;
+# Netscape's hacked uname
+    xx:WINNT:*)
+	echo i586-pc-msvc
+	exit 0 ;;
+    i*:PW*:*)
+	echo ${UNAME_MACHINE}-pc-pw32
+	exit 0 ;;
+    i*:Windows_NT*:* | Pentium*:Windows_NT*:*)
+	# How do we know it's Interix rather than the generic POSIX subsystem?
+	# It also conflicts with pre-2.0 versions of AT&T UWIN. Should we
+	# UNAME_MACHINE based on the output of uname instead of i386?
+	echo i386-pc-interix
+	exit 0 ;;
+    i*:UWIN*:*)
+	echo ${UNAME_MACHINE}-pc-uwin
+	exit 0 ;;
     p*:CYGWIN*:*)
-	echo powerpcle-unknown-cygwin32
+	echo powerpcle-unknown-cygwin
 	exit 0 ;;
     prep*:SunOS:5.*:*)
 	echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
 	exit 0 ;;
     *:GNU:*:*)
 	echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
 	exit 0 ;;
+    i*86:Minix:*:*)
+	echo ${UNAME_MACHINE}-pc-minix
+	exit 0 ;;
     *:Linux:*:*)
-	# uname on the ARM produces all sorts of strangeness, and we need to
-	# filter it out.
-	case "$UNAME_MACHINE" in
-	  arm* | sa110*)	      UNAME_MACHINE="arm" ;;
-	esac
 
 	# The BFD linker knows what the default object file format is, so
-	# first see if it will tell us.
-	ld_help_string=`ld --help 2>&1`
-	ld_supported_emulations=`echo $ld_help_string \
+	# first see if it will tell us. cd to the root directory to prevent
+	# problems with other programs or directories called `ld' in the path.
+	ld_supported_emulations=`cd /; ld --help 2>&1 \
 			 | sed -ne '/supported emulations:/!d
 				    s/[ 	][ 	]*/ /g
 				    s/.*supported emulations: *//
 				    s/ .*//
 				    p'`
         case "$ld_supported_emulations" in
-	  i?86linux)  echo "${UNAME_MACHINE}-pc-linux-gnuaout"      ; exit 0 ;;
-	  i?86coff)   echo "${UNAME_MACHINE}-pc-linux-gnucoff"      ; exit 0 ;;
-	  sparclinux) echo "${UNAME_MACHINE}-unknown-linux-gnuaout" ; exit 0 ;;
-	  armlinux)   echo "${UNAME_MACHINE}-unknown-linux-gnuaout" ; exit 0 ;;
-	  m68klinux)  echo "${UNAME_MACHINE}-unknown-linux-gnuaout" ; exit 0 ;;
-	  elf32ppc)   echo "powerpc-unknown-linux-gnu"              ; exit 0 ;;
+	  *ia64)
+		echo "${UNAME_MACHINE}-unknown-linux"
+		exit 0
+		;;
+	  i?86linux)
+		echo "${UNAME_MACHINE}-pc-linux-gnuaout"
+		exit 0
+		;;
+	  elf_i?86)
+		TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu"
+		;;
+	  i?86coff)
+		echo "${UNAME_MACHINE}-pc-linux-gnucoff"
+		exit 0
+		;;
+	  sparclinux)
+		echo "${UNAME_MACHINE}-unknown-linux-gnuaout"
+		exit 0
+		;;
+	  elf32_sparc)
+		echo "${UNAME_MACHINE}-unknown-linux-gnu"
+		exit 0
+		;;
+	  armlinux)
+		echo "${UNAME_MACHINE}-unknown-linux-gnuaout"
+		exit 0
+		;;
+	  elf32arm*)
+		echo "${UNAME_MACHINE}-unknown-linux-gnuoldld"
+		exit 0
+		;;
+	  armelf_linux*)
+		echo "${UNAME_MACHINE}-unknown-linux-gnu"
+		exit 0
+		;;
+	  m68klinux)
+		echo "${UNAME_MACHINE}-unknown-linux-gnuaout"
+		exit 0
+		;;
+	  elf32ppc | elf32ppclinux)
+		# Determine Lib Version
+		cat >$dummy.c <<EOF
+#include <features.h>
+#if defined(__GLIBC__)
+extern char __libc_version[];
+extern char __libc_release[];
+#endif
+main(argc, argv)
+     int argc;
+     char *argv[];
+{
+#if defined(__GLIBC__)
+  printf("%s %s\n", __libc_version, __libc_release);
+#else
+  printf("unkown\n");
+#endif
+  return 0;
+}
+EOF
+		LIBC=""
+		$CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null
+		if test "$?" = 0 ; then
+			./$dummy | grep 1\.99 > /dev/null
+			if test "$?" = 0 ; then
+				LIBC="libc1"
+			fi
+		fi
+		rm -f $dummy.c $dummy
+		echo powerpc-unknown-linux-gnu${LIBC}
+		exit 0
+		;;
+	  shelf_linux)
+		echo "${UNAME_MACHINE}-unknown-linux-gnu"
+		exit 0
+		;;
 	esac
 
 	if test "${UNAME_MACHINE}" = "alpha" ; then
-		sed 's/^	//'  <<EOF >dummy.s
-		.globl main
-		.ent main
-	main:
-		.frame \$30,0,\$26,0
-		.prologue 0
-		.long 0x47e03d80 # implver $0
-		lda \$2,259
-		.long 0x47e20c21 # amask $2,$1
-		srl \$1,8,\$2
-		sll \$2,2,\$2
-		sll \$0,3,\$0
-		addl \$1,\$0,\$0
-		addl \$2,\$0,\$0
-		ret \$31,(\$26),1
-		.end main
+		cat <<EOF >$dummy.s
+			.data
+		\$Lformat:
+			.byte 37,100,45,37,120,10,0	# "%d-%x\n"
+
+			.text
+			.globl main
+			.align 4
+			.ent main
+		main:
+			.frame \$30,16,\$26,0
+			ldgp \$29,0(\$27)
+			.prologue 1
+			.long 0x47e03d80 # implver \$0
+			lda \$2,-1
+			.long 0x47e20c21 # amask \$2,\$1
+			lda \$16,\$Lformat
+			mov \$0,\$17
+			not \$1,\$18
+			jsr \$26,printf
+			ldgp \$29,0(\$26)
+			mov 0,\$16
+			jsr \$26,exit
+			.end main
 EOF
 		LIBC=""
-		${CC-cc} dummy.s -o dummy 2>/dev/null
+		$CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null
 		if test "$?" = 0 ; then
-			./dummy
-			case "$?" in
-			7)
+			case `./$dummy` in
+			0-0)
 				UNAME_MACHINE="alpha"
 				;;
-			15)
+			1-0)
 				UNAME_MACHINE="alphaev5"
 				;;
-			14)
+			1-1)
 				UNAME_MACHINE="alphaev56"
 				;;
-			10)
+			1-101)
 				UNAME_MACHINE="alphapca56"
 				;;
-			16)
+			2-303)
 				UNAME_MACHINE="alphaev6"
 				;;
-			esac	
+			2-307)
+				UNAME_MACHINE="alphaev67"
+				;;
+			esac
 
-			objdump --private-headers dummy | \
+			objdump --private-headers $dummy | \
 			  grep ld.so.1 > /dev/null
 			if test "$?" = 0 ; then
 				LIBC="libc1"
 			fi
-		fi	
-		rm -f dummy.s dummy
+		fi
+		rm -f $dummy.s $dummy
 		echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} ; exit 0
 	elif test "${UNAME_MACHINE}" = "mips" ; then
-	  cat >dummy.c <<EOF
-main(argc, argv)
-     int argc;
-     char *argv[];
-{
+	  cat >$dummy.c <<EOF
+#ifdef __cplusplus
+#include <stdio.h>  /* for printf() prototype */
+	int main (int argc, char *argv[]) {
+#else
+	int main (argc, argv) int argc; char *argv[]; {
+#endif
 #ifdef __MIPSEB__
   printf ("%s-unknown-linux-gnu\n", argv[1]);
 #endif
 #ifdef __MIPSEL__
   printf ("%sel-unknown-linux-gnu\n", argv[1]);
 #endif
   return 0;
 }
 EOF
-	  ${CC-cc} dummy.c -o dummy 2>/dev/null && ./dummy "${UNAME_MACHINE}" && rm dummy.c dummy && exit 0
-	  rm -f dummy.c dummy
+	  $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy "${UNAME_MACHINE}" && rm $dummy.c $dummy && exit 0
+	  rm -f $dummy.c $dummy
+	elif test "${UNAME_MACHINE}" = "s390"; then
+	  echo s390-ibm-linux && exit 0
+	elif test "${UNAME_MACHINE}" = "x86_64"; then
+	  echo x86_64-unknown-linux-gnu && exit 0
+	elif test "${UNAME_MACHINE}" = "parisc" -o "${UNAME_MACHINE}" = "hppa"; then
+	  # Look for CPU level
+	  case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
+	    PA7*)
+		echo hppa1.1-unknown-linux-gnu
+		;;
+	    PA8*)
+		echo hppa2.0-unknown-linux-gnu
+		;;
+	    *)
+		echo hppa-unknown-linux-gnu
+		;;
+	  esac
+	  exit 0
 	else
 	  # Either a pre-BFD a.out linker (linux-gnuoldld)
 	  # or one that does not give us useful --help.
 	  # GCC wants to distinguish between linux-gnuoldld and linux-gnuaout.
 	  # If ld does not provide *any* "supported emulations:"
 	  # that means it is gnuoldld.
-	  echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations:"
-	  test $? != 0 && echo "${UNAME_MACHINE}-pc-linux-gnuoldld" && exit 0
+	  test -z "$ld_supported_emulations" \
+	    && echo "${UNAME_MACHINE}-pc-linux-gnuoldld" && exit 0
 
 	  case "${UNAME_MACHINE}" in
 	  i?86)
 	    VENDOR=pc;
 	    ;;
 	  *)
 	    VENDOR=unknown;
 	    ;;
 	  esac
 	  # Determine whether the default compiler is a.out or elf
-	  cat >dummy.c <<EOF
+	  cat >$dummy.c <<EOF
 #include <features.h>
-main(argc, argv)
-     int argc;
-     char *argv[];
-{
+#ifdef __cplusplus
+#include <stdio.h>  /* for printf() prototype */
+	int main (int argc, char *argv[]) {
+#else
+	int main (argc, argv) int argc; char *argv[]; {
+#endif
 #ifdef __ELF__
 # ifdef __GLIBC__
 #  if __GLIBC__ >= 2
     printf ("%s-${VENDOR}-linux-gnu\n", argv[1]);
 #  else
     printf ("%s-${VENDOR}-linux-gnulibc1\n", argv[1]);
 #  endif
 # else
    printf ("%s-${VENDOR}-linux-gnulibc1\n", argv[1]);
 # endif
 #else
   printf ("%s-${VENDOR}-linux-gnuaout\n", argv[1]);
 #endif
   return 0;
 }
 EOF
-	  ${CC-cc} dummy.c -o dummy 2>/dev/null && ./dummy "${UNAME_MACHINE}" && rm dummy.c dummy && exit 0
-	  rm -f dummy.c dummy
+	  $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy "${UNAME_MACHINE}" && rm $dummy.c $dummy && exit 0
+	  rm -f $dummy.c $dummy
+	  test x"${TENTATIVE}" != x && echo "${TENTATIVE}" && exit 0
 	fi ;;
 # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.  earlier versions
 # are messed up and put the nodename in both sysname and nodename.
     i?86:DYNIX/ptx:4*:*)
 	echo i386-sequent-sysv4
 	exit 0 ;;
     i?86:UNIX_SV:4.2MP:2.*)
         # Unixware is an offshoot of SVR4, but it has its own version
         # number series starting with 2...
         # I am not positive that other SVR4 systems won't match this,
 	# I just have to hope.  -- rms.
         # Use sysv4.2uw... so that sysv4* matches it.
 	echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
 	exit 0 ;;
     i?86:*:4.*:* | i?86:SYSTEM_V:4.*:*)
+	UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'`
 	if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
-		echo ${UNAME_MACHINE}-univel-sysv${UNAME_RELEASE}
+		echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL}
 	else
-		echo ${UNAME_MACHINE}-pc-sysv${UNAME_RELEASE}
+		echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL}
+	fi
+	exit 0 ;;
+    i?86:*:5:7*)
+        # Fixed at (any) Pentium or better
+        UNAME_MACHINE=i586
+        if [ ${UNAME_SYSTEM} = "UnixWare" ] ; then
+	    echo ${UNAME_MACHINE}-sco-sysv${UNAME_RELEASE}uw${UNAME_VERSION}
+	else
+	    echo ${UNAME_MACHINE}-pc-sysv${UNAME_RELEASE}
 	fi
 	exit 0 ;;
     i?86:*:3.2:*)
 	if test -f /usr/options/cb.name; then
 		UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
 		echo ${UNAME_MACHINE}-pc-isc$UNAME_REL
 	elif /bin/uname -X 2>/dev/null >/dev/null ; then
 		UNAME_REL=`(/bin/uname -X|egrep Release|sed -e 's/.*= //')`
 		(/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486
 		(/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) \
 			&& UNAME_MACHINE=i586
+		(/bin/uname -X|egrep '^Machine.*Pent ?II' >/dev/null) \
+			&& UNAME_MACHINE=i686
+		(/bin/uname -X|egrep '^Machine.*Pentium Pro' >/dev/null) \
+			&& UNAME_MACHINE=i686
 		echo ${UNAME_MACHINE}-pc-sco$UNAME_REL
 	else
 		echo ${UNAME_MACHINE}-pc-sysv32
 	fi
 	exit 0 ;;
+    i?86:*DOS:*:*)
+	echo ${UNAME_MACHINE}-pc-msdosdjgpp
+	exit 0 ;;
     pc:*:*:*)
+	# Left here for compatibility:
         # uname -m prints for DJGPP always 'pc', but it prints nothing about
         # the processor, so we play safe by assuming i386.
 	echo i386-pc-msdosdjgpp
         exit 0 ;;
     Intel:Mach:3*:*)
 	echo i386-pc-mach3
 	exit 0 ;;
     paragon:*:*:*)
@@ -678,45 +1064,48 @@ EOF
 	fi
 	exit 0 ;;
     mini*:CTIX:SYS*5:*)
 	# "miniframe"
 	echo m68010-convergent-sysv
 	exit 0 ;;
     M68*:*:R3V[567]*:*)
 	test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;;
-    3[34]??:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 4850:*:4.0:3.0)
+    3[34]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 4850:*:4.0:3.0)
 	OS_REL=''
 	test -r /etc/.relid \
 	&& OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
 	/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
 	  && echo i486-ncr-sysv4.3${OS_REL} && exit 0
 	/bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
 	  && echo i586-ncr-sysv4.3${OS_REL} && exit 0 ;;
     3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
         /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
           && echo i486-ncr-sysv4 && exit 0 ;;
     m68*:LynxOS:2.*:*)
 	echo m68k-unknown-lynxos${UNAME_RELEASE}
 	exit 0 ;;
     mc68030:UNIX_System_V:4.*:*)
 	echo m68k-atari-sysv4
 	exit 0 ;;
-    i?86:LynxOS:2.*:*)
+    i?86:LynxOS:2.*:* | i?86:LynxOS:3.[01]*:*)
 	echo i386-unknown-lynxos${UNAME_RELEASE}
 	exit 0 ;;
     TSUNAMI:LynxOS:2.*:*)
 	echo sparc-unknown-lynxos${UNAME_RELEASE}
 	exit 0 ;;
     rs6000:LynxOS:2.*:* | PowerPC:LynxOS:2.*:*)
 	echo rs6000-unknown-lynxos${UNAME_RELEASE}
 	exit 0 ;;
     SM[BE]S:UNIX_SV:*:*)
 	echo mips-dde-sysv${UNAME_RELEASE}
 	exit 0 ;;
+    RM*:ReliantUNIX-*:*:*)
+	echo mips-sni-sysv4
+	exit 0 ;;
     RM*:SINIX-*:*:*)
 	echo mips-sni-sysv4
 	exit 0 ;;
     *:SINIX-*:*:*)
 	if uname -p 2>/dev/null >/dev/null ; then
 		UNAME_MACHINE=`(uname -p) 2>/dev/null`
 		echo ${UNAME_MACHINE}-sni-sysv4
 	else
@@ -731,54 +1120,96 @@ EOF
 	# From Gerald Hewes <hewes@openmarket.com>.
 	# How about differentiating between stratus architectures? -djm
 	echo hppa1.1-stratus-sysv4
 	exit 0 ;;
     *:*:*:FTX*)
 	# From seanf@swdc.stratus.com.
 	echo i860-stratus-sysv4
 	exit 0 ;;
-	*:Rhapsody:*:*)
-	test ! -z "`echo ${UNAME_MACHINE} | grep Power`" && echo ppc-apple-rhapsody${UNAME_RELEASE} && exit 0
-	echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
-	exit 0 ;;
     mc68*:A/UX:*:*)
 	echo m68k-apple-aux${UNAME_RELEASE}
 	exit 0 ;;
-    news*:NEWS-OS:*:6*)
+    news*:NEWS-OS:6*:*)
 	echo mips-sony-newsos6
 	exit 0 ;;
-    R3000:*System_V*:*:* | R4000:UNIX_SYSV:*:*)
+    R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
 	if [ -d /usr/nec ]; then
 	        echo mips-nec-sysv${UNAME_RELEASE}
 	else
 	        echo mips-unknown-sysv${UNAME_RELEASE}
 	fi
         exit 0 ;;
-    *:QNX:*:*)
-	echo i386-pc-qnx`${UNAME_VERSION} | cut -c1-1`
+    BeBox:BeOS:*:*)	# BeOS running on hardware made by Be, PPC only.
+	echo powerpc-be-beos
+	exit 0 ;;
+    BeMac:BeOS:*:*)	# BeOS running on Mac or Mac clone, PPC only.
+	echo powerpc-apple-beos
+	exit 0 ;;
+    BePC:BeOS:*:*)	# BeOS running on Intel PC compatible.
+	echo i586-pc-beos
+	exit 0 ;;
+    SX-4:SUPER-UX:*:*)
+	echo sx4-nec-superux${UNAME_RELEASE}
+	exit 0 ;;
+    SX-5:SUPER-UX:*:*)
+	echo sx5-nec-superux${UNAME_RELEASE}
 	exit 0 ;;
-    *:*nto:*:*)
-	echo `uname -p`-pc-nto
+    Power*:Rhapsody:*:*)
+	echo powerpc-apple-rhapsody${UNAME_RELEASE}
+	exit 0 ;;
+    *:Rhapsody:*:*)
+	echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
+	exit 0 ;;
+    *:Darwin:*:*)
+	echo `uname -p`-apple-darwin${UNAME_RELEASE}
+	exit 0 ;;
+    *:procnto*:*:* | *:QNX:[0123456789]*:*)
+	if test "${UNAME_MACHINE}" = "x86pc"; then
+		UNAME_MACHINE=pc
+	fi
+	echo `uname -p`-${UNAME_MACHINE}-nto-qnx
 	exit 0 ;;
-    BePC:BeOS:*:*)
-        echo i386-pc-beos${UNAME_RELEASE}
-        exit 0 ;;
-    BeMac:BeOS:*:*)
-        echo ppc-apple-beos${UNAME_RELEASE}
-        exit 0 ;;
-    BeBox:BeOS:*:*)
-        echo ppc-be-beos${UNAME_RELEASE}
-        exit 0 ;;
+    *:QNX:*:4*)
+	echo i386-pc-qnx
+	exit 0 ;;
+    NSR-[KW]:NONSTOP_KERNEL:*:*)
+	echo nsr-tandem-nsk${UNAME_RELEASE}
+	exit 0 ;;
+    *:NonStop-UX:*:*)
+	echo mips-compaq-nonstopux
+	exit 0 ;;
+    BS2000:POSIX*:*:*)
+	echo bs2000-siemens-sysv
+	exit 0 ;;
+    DS/*:UNIX_System_V:*:*)
+	echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE}
+	exit 0 ;;
+    *:Plan9:*:*)
+	# "uname -m" is not consistent, so use $cputype instead. 386
+	# is converted to i386 for consistency with other x86
+	# operating systems.
+	if test "$cputype" = "386"; then
+	    UNAME_MACHINE=i386
+	else
+	    UNAME_MACHINE="$cputype"
+	fi
+	echo ${UNAME_MACHINE}-unknown-plan9
+	exit 0 ;;
+    i?86:OS/2:*:*)
+	# If we were able to find `uname', then EMX Unix compatibility
+	# is probably installed.
+	echo ${UNAME_MACHINE}-pc-os2-emx
+	exit 0 ;;
 esac
 
 #echo '(No uname command or uname output not recognized.)' 1>&2
 #echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2
 
-cat >dummy.c <<EOF
+cat >$dummy.c <<EOF
 #ifdef _SEQUENT_
 # include <sys/types.h>
 # include <sys/utsname.h>
 #endif
 main ()
 {
 #if defined (sony)
 #if defined (MIPSEB)
@@ -806,17 +1237,20 @@ main ()
 #endif
 
 #if defined (NeXT)
 #if !defined (__ARCHITECTURE__)
 #define __ARCHITECTURE__ "m68k"
 #endif
   int version;
   version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
-  printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
+  if (version < 4)
+    printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
+  else
+    printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version);
   exit (0);
 #endif
 
 #if defined (MULTIMAX) || defined (n16)
 #if defined (UMAXV)
   printf ("ns32k-encore-sysv\n"); exit (0);
 #else
 #if defined (CMU)
@@ -866,18 +1300,18 @@ main ()
 #if defined (alliant) && defined (i860)
   printf ("i860-alliant-bsd\n"); exit (0);
 #endif
 
   exit (1);
 }
 EOF
 
-${CC-cc} dummy.c -o dummy 2>/dev/null && ./dummy && rm dummy.c dummy && exit 0
-rm -f dummy.c dummy
+$CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy && rm $dummy.c $dummy && exit 0
+rm -f $dummy.c $dummy
 
 # Apollos put the system type in the environment.
 
 test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; }
 
 # Convex versions that predate uname can use getsysinfo(1)
 
 if [ -x /usr/convex/getsysinfo ]
@@ -899,11 +1333,52 @@ then
 	echo c38-convex-bsd
 	exit 0 ;;
     c4*)
 	echo c4-convex-bsd
 	exit 0 ;;
     esac
 fi
 
-#echo '(Unable to guess system type)' 1>&2
+cat >&2 <<EOF
+$0: unable to guess system type
+
+The $version version of this script cannot recognize your system type.
+Please download the most up to date version of the config scripts:
+
+    ftp://ftp.gnu.org/pub/gnu/config/
+
+If the version you run ($0) is already up to date, please
+send the following data and any information you think might be
+pertinent to <config-patches@gnu.org> in order to provide the needed
+information to handle your system.
+
+config.guess version = $version
+
+uname -m = `(uname -m) 2>/dev/null || echo unknown`
+uname -r = `(uname -r) 2>/dev/null || echo unknown`
+uname -s = `(uname -s) 2>/dev/null || echo unknown`
+uname -v = `(uname -v) 2>/dev/null || echo unknown`
+
+/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null`
+/bin/uname -X     = `(/bin/uname -X) 2>/dev/null`
+
+hostinfo               = `(hostinfo) 2>/dev/null`
+/bin/universe          = `(/bin/universe) 2>/dev/null`
+/usr/bin/arch -k       = `(/usr/bin/arch -k) 2>/dev/null`
+/bin/arch              = `(/bin/arch) 2>/dev/null`
+/usr/bin/oslevel       = `(/usr/bin/oslevel) 2>/dev/null`
+/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null`
+
+UNAME_MACHINE = ${UNAME_MACHINE}
+UNAME_RELEASE = ${UNAME_RELEASE}
+UNAME_SYSTEM  = ${UNAME_SYSTEM}
+UNAME_VERSION = ${UNAME_VERSION}
+EOF
 
 exit 1
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "timestamp='"
+# time-stamp-format: "%:y-%02m-%02d"
+# time-stamp-end: "'"
+# End:
--- a/build/autoconf/config.sub
+++ b/build/autoconf/config.sub
@@ -1,11 +1,15 @@
 #! /bin/sh
-# Configuration validation subroutine script, version 1.1.
-#   Copyright (C) 1991, 92-97, 1998 Free Software Foundation, Inc.
+# Configuration validation subroutine script.
+#   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
+#   Free Software Foundation, Inc.
+
+timestamp='2001-01-01'
+
 # This file is (in principle) common to ALL GNU software.
 # The presence of a machine in this file suggests that SOME GNU software
 # can handle that machine.  It does not imply ALL GNU software can.
 #
 # This file is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
 # the Free Software Foundation; either version 2 of the License, or
 # (at your option) any later version.
@@ -20,16 +24,18 @@
 # Foundation, Inc., 59 Temple Place - Suite 330,
 # Boston, MA 02111-1307, USA.
 
 # As a special exception to the GNU General Public License, if you
 # distribute this file as part of a program that contains a
 # configuration script generated by Autoconf, you may include it under
 # the same distribution terms that you use for the rest of that program.
 
+# Please send patches to <config-patches@gnu.org>.
+#
 # Configuration subroutine to validate and canonicalize a configuration type.
 # Supply the specified configuration type as an argument.
 # If it is invalid, we print an error message on stderr and exit with code 1.
 # Otherwise, we print the canonical config type on stdout and succeed.
 
 # This file is supposed to be the same for all GNU packages
 # and recognize all the CPU types, system types and aliases
 # that are meaningful with *any* GNU software.
@@ -40,40 +46,83 @@
 
 # The goal of this file is to map all the various variations of a given
 # machine specification into a single specification in the form:
 #	CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
 # or in some cases, the newer four-part form:
 #	CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
 # It is wrong to echo any other type of specification.
 
-if [ x$1 = x ]
-then
-	echo Configuration name missing. 1>&2
-	echo "Usage: $0 CPU-MFR-OPSYS" 1>&2
-	echo "or     $0 ALIAS" 1>&2
-	echo where ALIAS is a recognized configuration type. 1>&2
-	exit 1
-fi
+me=`echo "$0" | sed -e 's,.*/,,'`
+
+usage="\
+Usage: $0 [OPTION] CPU-MFR-OPSYS
+       $0 [OPTION] ALIAS
+
+Canonicalize a configuration name.
+
+Operation modes:
+  -h, --help         print this help, then exit
+  -t, --time-stamp   print date of last modification, then exit
+  -v, --version      print version number, then exit
+
+Report bugs and patches to <config-patches@gnu.org>."
+
+version="\
+GNU config.sub ($timestamp)
+
+Copyright (C) 1992, 93, 94, 95, 96, 97, 98, 99, 2000
+Free Software Foundation, Inc.
+
+This is free software; see the source for copying conditions.  There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
+
+help="
+Try \`$me --help' for more information."
 
-# First pass through any local machine types.
-case $1 in
-	*local*)
-		echo $1
-		exit 0
-		;;
-	*)
-	;;
+# Parse command line
+while test $# -gt 0 ; do
+  case $1 in
+    --time-stamp | --time* | -t )
+       echo "$timestamp" ; exit 0 ;;
+    --version | -v )
+       echo "$version" ; exit 0 ;;
+    --help | --h* | -h )
+       echo "$usage"; exit 0 ;;
+    -- )     # Stop option processing
+       shift; break ;;
+    - )	# Use stdin as input.
+       break ;;
+    -* )
+       echo "$me: invalid option $1$help"
+       exit 1 ;;
+
+    *local*)
+       # First pass through any local machine types.
+       echo $1
+       exit 0;;
+
+    * )
+       break ;;
+  esac
+done
+
+case $# in
+ 0) echo "$me: missing argument$help" >&2
+    exit 1;;
+ 1) ;;
+ *) echo "$me: too many arguments$help" >&2
+    exit 1;;
 esac
 
 # Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any).
 # Here we must recognize all the valid KERNEL-OS combinations.
 maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
 case $maybe_os in
-  linux-gnu*)
+  nto-qnx* | linux-gnu* | storm-chaos*)
     os=-$maybe_os
     basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
     ;;
   *)
     basic_machine=`echo $1 | sed 's/-[^-]*$//'`
     if [ $basic_machine != $1 ]
     then os=`echo $1 | sed 's/.*-/-/'`
     else os=; fi
@@ -89,25 +138,35 @@ case $os in
 		# Prevent following clause from handling this invalid input.
 		;;
 	-dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \
 	-att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \
 	-unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \
 	-convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
 	-c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
 	-harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
-	-apple)
+	-apple | -axis)
+		os=
+		basic_machine=$1
+		;;
+	-sim | -cisco | -oki | -wec | -winbond)
 		os=
 		basic_machine=$1
 		;;
+	-scout)
+		;;
+	-wrs)
+		os=-vxworks
+		basic_machine=$1
+		;;
 	-hiux*)
 		os=-hiuxwe2
 		;;
 	-sco5)
-		os=sco3.2v5
+		os=-sco3.2v5
 		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
 		;;
 	-sco4)
 		os=-sco3.2v4
 		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
 		;;
 	-sco3.2.[4-9]*)
 		os=`echo $os | sed -e 's/sco3.2./sco3.2v/'`
@@ -116,16 +175,19 @@ case $os in
 	-sco3.2v[4-9]*)
 		# Don't forget version if it is 3.2v4 or newer.
 		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
 		;;
 	-sco*)
 		os=-sco3.2v2
 		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
 		;;
+	-udk*)
+		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+		;;
 	-isc)
 		os=-isc2.2
 		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
 		;;
 	-clix*)
 		basic_machine=clipper-intergraph
 		;;
 	-isc*)
@@ -138,106 +200,142 @@ case $os in
 		basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'`
 		;;
 	-windowsnt*)
 		os=`echo $os | sed -e 's/windowsnt/winnt/'`
 		;;
 	-psos*)
 		os=-psos
 		;;
-	-qnx*)
-		basic_machine=x6-pc
-		os=-qnx`uname -v | cut -c1-1`
-		;;
-	-nto*)
-		basic_machine=`uname -p`-pc
-		os=-nto
-		;;
-	-rhapsody*)
-		basic_machine=ppc-apple
-		os=-rhapsody`uname -r`
+	-mint | -mint[0-9]*)
+		basic_machine=m68k-atari
+		os=-mint
 		;;
 esac
 
 # Decode aliases for certain CPU-COMPANY combinations.
 case $basic_machine in
 	# Recognize the basic CPU types without company name.
 	# Some are omitted here because they have special meanings below.
-	tahoe | i860 | m32r | m68k | m68000 | m88k | ns32k | arc | arm \
-		| arme[lb] | pyramid | mn10200 | mn10300 \
-		| tron | a29k | 580 | i960 | h8300 | hppa | hppa1.0 | hppa1.1 \
-		| alpha | alphaev5 | alphaev56 | alphaev6 | alphapca56 | we32k | ns16k | clipper \
-		| i370 | sh | powerpc | powerpcle | 1750a | dsp16xx | pdp11 \
-		| mips64 | mipsel | mips64el | mips64orion | mips64orionel \
-		| mipstx39 | mipstx39el \
-		| sparc | sparclet | sparclite | sparc64 | v850)
+	tahoe | i860 | ia64 | m32r | m68k | m68000 | m88k | ns32k | arc \
+	        | arm | arme[lb] | arm[bl]e | armv[2345] | armv[345][lb] | strongarm | xscale \
+		| pyramid | mn10200 | mn10300 | tron | a29k \
+		| 580 | i960 | h8300 \
+		| x86 | ppcbe | mipsbe | mipsle | shbe | shle \
+		| hppa | hppa1.0 | hppa1.1 | hppa2.0 | hppa2.0w | hppa2.0n \
+		| hppa64 \
+		| alpha | alphaev[4-8] | alphaev56 | alphapca5[67] \
+		| alphaev6[78] \
+		| we32k | ns16k | clipper | i370 | sh | sh[34] \
+		| powerpc | powerpcle \
+		| 1750a | dsp16xx | pdp11 | mips16 | mips64 | mipsel | mips64el \
+		| mips64orion | mips64orionel | mipstx39 | mipstx39el \
+		| mips64vr4300 | mips64vr4300el | mips64vr4100 | mips64vr4100el \
+		| mips64vr5000 | miprs64vr5000el | mcore \
+		| sparc | sparclet | sparclite | sparc64 | sparcv9 | v850 | c4x \
+		| thumb | d10v | d30v | fr30 | avr)
 		basic_machine=$basic_machine-unknown
 		;;
+	m6811 | m68hc11 | m6812 | m68hc12)
+		# Motorola 68HC11/12.
+		basic_machine=$basic_machine-unknown
+		os=-none
+		;;
+	m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | z8k | v70 | h8500 | w65 | pj | pjl)
+		;;
+
 	# We use `pc' rather than `unknown'
 	# because (1) that's what they normally are, and
 	# (2) the word "unknown" tends to confuse beginning users.
-	i[34567]86)
+	i[234567]86 | x86_64)
 	  basic_machine=$basic_machine-pc
 	  ;;
 	# Object if more than one company name word.
 	*-*-*)
 		echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
 		exit 1
 		;;
 	# Recognize the basic CPU types with company name.
-	vax-* | tahoe-* | i[34567]86-* | i860-* | m32r-* | m68k-* | m68000-* \
-	      | m88k-* | sparc-* | ns32k-* | fx80-* | arc-* | arm-* | c[123]* \
+	# FIXME: clean up the formatting here.
+	vax-* | tahoe-* | i[234567]86-* | i860-* | ia64-* | m32r-* | m68k-* | m68000-* \
+	      | m88k-* | sparc-* | ns32k-* | fx80-* | arc-* | c[123]* \
+	      | arm-*  | armbe-* | armle-* | armv*-* | strongarm-* | xscale-* \
 	      | mips-* | pyramid-* | tron-* | a29k-* | romp-* | rs6000-* \
-	      | power-* | none-* | 580-* | cray2-* | h8300-* | i960-* \
-	      | xmp-* | ymp-* | hppa-* | hppa1.0-* | hppa1.1-* \
-	      | alpha-* | alphaev5-* | alphaev56-* | alphaev6-* | alphapca56-* | we32k-* | cydra-* \
-	      | ns16k-* | pn-* | np1-* | xps100-* | clipper-* | orion-* \
+	      | power-* | none-* | 580-* | cray2-* | h8300-* | h8500-* | i960-* \
+	      | xmp-* | ymp-* \
+	      | x86-* | ppcbe-* | mipsbe-* | mipsle-* | shbe-* | shle-* \
+	      | hppa-* | hppa1.0-* | hppa1.1-* | hppa2.0-* | hppa2.0w-* \
+	      | hppa2.0n-* | hppa64-* \
+	      | alpha-* | alphaev[4-8]-* | alphaev56-* | alphapca5[67]-* \
+	      | alphaev6[78]-* \
+	      | we32k-* | cydra-* | ns16k-* | pn-* | np1-* | xps100-* \
+	      | clipper-* | orion-* \
 	      | sparclite-* | pdp11-* | sh-* | powerpc-* | powerpcle-* \
-	      | sparc64-* | mips64-* | mipsel-* \
-	      | mips64el-* | mips64orion-* | mips64orionel-*  \
-	      | mipstx39-* | mipstx39el-* \
-	      | f301-*)
+	      | sparc64-* | sparcv9-* | sparc86x-* | mips16-* | mips64-* | mipsel-* \
+	      | mips64el-* | mips64orion-* | mips64orionel-* \
+	      | mips64vr4100-* | mips64vr4100el-* | mips64vr4300-* | mips64vr4300el-* \
+	      | mipstx39-* | mipstx39el-* | mcore-* \
+	      | f30[01]-* | f700-* | s390-* | sv1-* | t3e-* \
+	      | m88110-* | m680[01234]0-* | m683?2-* | m68360-* | z8k-* | d10v-* \
+	      | thumb-* | v850-* | d30v-* | tic30-* | c30-* | fr30-* \
+	      | bs2000-* | tic54x-* | c54x-* | x86_64-*)
 		;;
 	# Recognize the various machine names and aliases which stand
 	# for a CPU type and a company and sometimes even an OS.
+	386bsd)
+		basic_machine=i386-unknown
+		os=-bsd
+		;;
 	3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
 		basic_machine=m68000-att
 		;;
 	3b*)
 		basic_machine=we32k-att
 		;;
+	a29khif)
+		basic_machine=a29k-amd
+		os=-udi
+		;;
+	adobe68k)
+		basic_machine=m68010-adobe
+		os=-scout
+		;;
 	alliant | fx80)
 		basic_machine=fx80-alliant
 		;;
 	altos | altos3068)
 		basic_machine=m68k-altos
 		;;
 	am29k)
 		basic_machine=a29k-none
 		os=-bsd
 		;;
 	amdahl)
 		basic_machine=580-amdahl
 		os=-sysv
 		;;
 	amiga | amiga-*)
-		basic_machine=m68k-cbm
+		basic_machine=m68k-unknown
 		;;
 	amigaos | amigados)
-		basic_machine=m68k-cbm
+		basic_machine=m68k-unknown
 		os=-amigaos
 		;;
 	amigaunix | amix)
-		basic_machine=m68k-cbm
+		basic_machine=m68k-unknown
 		os=-sysv4
 		;;
 	apollo68)
 		basic_machine=m68k-apollo
 		os=-sysv
 		;;
+	apollo68bsd)
+		basic_machine=m68k-apollo
+		os=-bsd
+		;;
 	aux)
 		basic_machine=m68k-apple
 		os=-aux
 		;;
 	balance)
 		basic_machine=ns32k-sequent
 		os=-dynix
 		;;
@@ -271,16 +369,19 @@ case $basic_machine in
 		;;
 	[ctj]90-cray)
 		basic_machine=c90-cray
 		os=-unicos
 		;;
 	crds | unos)
 		basic_machine=m68k-crds
 		;;
+	cris | cris-* | etrax*)
+		basic_machine=cris-axis
+		;;
 	da30 | da30-*)
 		basic_machine=m68k-da30
 		;;
 	decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn)
 		basic_machine=mips-dec
 		;;
 	delta | 3300 | motorola-3300 | motorola-delta \
 	      | 3300-motorola | delta-motorola)
@@ -304,16 +405,20 @@ case $basic_machine in
 		;;
 	elxsi)
 		basic_machine=elxsi-elxsi
 		os=-bsd
 		;;
 	encore | umax | mmax)
 		basic_machine=ns32k-encore
 		;;
+	es1800 | OSE68k | ose68k | ose | OSE)
+		basic_machine=m68k-ericsson
+		os=-ose
+		;;
 	fx2800)
 		basic_machine=i860-alliant
 		;;
 	genix)
 		basic_machine=ns32k-ns
 		;;
 	gmicro)
 		basic_machine=tron-gmicro
@@ -322,49 +427,81 @@ case $basic_machine in
 	h3050r* | hiux*)
 		basic_machine=hppa1.1-hitachi
 		os=-hiuxwe2
 		;;
 	h8300hms)
 		basic_machine=h8300-hitachi
 		os=-hms
 		;;
+	h8300xray)
+		basic_machine=h8300-hitachi
+		os=-xray
+		;;
+	h8500hms)
+		basic_machine=h8500-hitachi
+		os=-hms
+		;;
 	harris)
 		basic_machine=m88k-harris
 		os=-sysv3
 		;;
 	hp300-*)
 		basic_machine=m68k-hp
 		;;
 	hp300bsd)
 		basic_machine=m68k-hp
 		os=-bsd
 		;;
 	hp300hpux)
 		basic_machine=m68k-hp
 		os=-hpux
 		;;
+	hp3k9[0-9][0-9] | hp9[0-9][0-9])
+		basic_machine=hppa1.0-hp
+		;;
 	hp9k2[0-9][0-9] | hp9k31[0-9])
 		basic_machine=m68000-hp
 		;;
 	hp9k3[2-9][0-9])
 		basic_machine=m68k-hp
 		;;
-	hp9k7[0-9][0-9] | hp7[0-9][0-9] | hp9k8[0-9]7 | hp8[0-9]7)
+	hp9k6[0-9][0-9] | hp6[0-9][0-9])
+		basic_machine=hppa1.0-hp
+		;;
+	hp9k7[0-79][0-9] | hp7[0-79][0-9])
+		basic_machine=hppa1.1-hp
+		;;
+	hp9k78[0-9] | hp78[0-9])
+		# FIXME: really hppa2.0-hp
+		basic_machine=hppa1.1-hp
+		;;
+	hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
+		# FIXME: really hppa2.0-hp
+		basic_machine=hppa1.1-hp
+		;;
+	hp9k8[0-9][13679] | hp8[0-9][13679])
 		basic_machine=hppa1.1-hp
 		;;
 	hp9k8[0-9][0-9] | hp8[0-9][0-9])
 		basic_machine=hppa1.0-hp
 		;;
 	hppa-next)
 		os=-nextstep3
 		;;
+	hppaosf)
+		basic_machine=hppa1.1-hp
+		os=-osf
+		;;
+	hppro)
+		basic_machine=hppa1.1-hp
+		os=-proelf
+		;;
 	i370-ibm* | ibm*)
 		basic_machine=i370-ibm
-		os=-mvs
 		;;
 # I'm not sure what "Sysv32" means.  Should this be sysv3.2?
 	i[34567]86v32)
 		basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
 		os=-sysv32
 		;;
 	i[34567]86v4*)
 		basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
@@ -373,16 +510,40 @@ case $basic_machine in
 	i[34567]86v)
 		basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
 		os=-sysv
 		;;
 	i[34567]86sol2)
 		basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
 		os=-solaris2
 		;;
+	i386mach)
+		basic_machine=i386-mach
+		os=-mach
+		;;
+	i386-vsta | vsta)
+		basic_machine=i386-unknown
+		os=-vsta
+		;;
+	i386-go32 | go32)
+		basic_machine=i386-unknown
+		os=-go32
+		;;
+	i386-mingw32 | mingw32)
+		basic_machine=i386-unknown
+		os=-mingw32
+		;;
+	i386-msvc | msvc)
+		basic_machine=i386-unknown
+		os=-msvc
+		;;
+	i[34567]86-pw32 | pw32)
+		basic_machine=i586-unknown
+		os=-pw32
+		;;
 	iris | iris4d)
 		basic_machine=mips-sgi
 		case $os in
 		    -irix*)
 			;;
 		    *)
 			os=-irix4
 			;;
@@ -401,46 +562,78 @@ case $basic_machine in
 		;;
 	merlin)
 		basic_machine=ns32k-utek
 		os=-sysv
 		;;
 	miniframe)
 		basic_machine=m68000-convergent
 		;;
+	*mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*)
+		basic_machine=m68k-atari
+		os=-mint
+		;;
 	mipsel*-linux*)
 		basic_machine=mipsel-unknown
 		os=-linux-gnu
 		;;
 	mips*-linux*)
 		basic_machine=mips-unknown
 		os=-linux-gnu
 		;;
 	mips3*-*)
 		basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
 		;;
 	mips3*)
 		basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
 		;;
+	mmix*)
+		basic_machine=mmix-knuth
+		os=-mmixware
+		;;
+	monitor)
+		basic_machine=m68k-rom68k
+		os=-coff
+		;;
+	msdos)
+		basic_machine=i386-unknown
+		os=-msdos
+		;;
+	mvs)
+		basic_machine=i370-ibm
+		os=-mvs
+		;;
 	ncr3000)
 		basic_machine=i486-ncr
 		os=-sysv4
 		;;
+	netbsd386)
+		basic_machine=i386-unknown
+		os=-netbsd
+		;;
+	netwinder)
+		basic_machine=armv4l-rebel
+		os=-linux
+		;;
 	news | news700 | news800 | news900)
 		basic_machine=m68k-sony
 		os=-newsos
 		;;
 	news1000)
 		basic_machine=m68030-sony
 		os=-newsos
 		;;
 	news-3600 | risc-news)
 		basic_machine=mips-sony
 		os=-newsos
 		;;
+	necv70)
+		basic_machine=v70-nec
+		os=-sysv
+		;;
 	next | m*-next )
 		basic_machine=m68k-next
 		case $os in
 		    -nextstep* )
 			;;
 		    -ns2*)
 		      os=-nextstep2
 			;;
@@ -456,19 +649,42 @@ case $basic_machine in
 	nh[45]000)
 		basic_machine=m88k-harris
 		os=-cxux
 		;;
 	nindy960)
 		basic_machine=i960-intel
 		os=-nindy
 		;;
+	mon960)
+		basic_machine=i960-intel
+		os=-mon960
+		;;
+	nonstopux)
+		basic_machine=mips-compaq
+		os=-nonstopux
+		;;
 	np1)
 		basic_machine=np1-gould
 		;;
+	nsr-tandem)
+		basic_machine=nsr-tandem
+		;;
+	op50n-* | op60c-*)
+		basic_machine=hppa1.1-oki
+		os=-proelf
+		;;
+	OSE68000 | ose68000)
+		basic_machine=m68000-ericsson
+		os=-ose
+		;;
+	os68k)
+		basic_machine=m68k-none
+		os=-os68k
+		;;
 	pa-hitachi)
 		basic_machine=hppa1.1-hitachi
 		os=-hiuxwe2
 		;;
 	paragon)
 		basic_machine=i860-intel
 		os=-osf
 		;;
@@ -476,80 +692,91 @@ case $basic_machine in
 		basic_machine=sparc-tti
 		;;
 	pbb)
 		basic_machine=m68k-tti
 		;;
         pc532 | pc532-*)
 		basic_machine=ns32k-pc532
 		;;
-	pentium | p5 | k5 | nexen)
+	pentium | p5 | k5 | k6 | nexgen)
 		basic_machine=i586-pc
 		;;
-	pentiumpro | p6 | k6 | 6x86)
+	pentiumpro | p6 | 6x86 | athlon)
 		basic_machine=i686-pc
 		;;
 	pentiumii | pentium2)
-		basic_machine=i786-pc
+		basic_machine=i686-pc
 		;;
-	pentium-* | p5-* | k5-* | nexen-*)
+	pentium-* | p5-* | k5-* | k6-* | nexgen-*)
 		basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
 		;;
-	pentiumpro-* | p6-* | k6-* | 6x86-*)
+	pentiumpro-* | p6-* | 6x86-* | athlon-*)
 		basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
 		;;
 	pentiumii-* | pentium2-*)
-		basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'`
+		basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
 		;;
 	pn)
 		basic_machine=pn-gould
 		;;
-	power)	basic_machine=rs6000-ibm
+	power)	basic_machine=power-ibm
 		;;
 	ppc)	basic_machine=powerpc-unknown
 	        ;;
 	ppc-*)	basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
 		;;
 	ppcle | powerpclittle | ppc-le | powerpc-little)
 		basic_machine=powerpcle-unknown
 	        ;;
 	ppcle-* | powerpclittle-*)
 		basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'`
 		;;
 	ps2)
 		basic_machine=i386-ibm
 		;;
-	*qnx*)
-		basic_machine=x86-pc
-		os=-qnx`uname -v | cut -c1-1`
-		;;
-	*nto*)
-		basic_machine=`uname -p`-pc
-		os=-nto
+	rom68k)
+		basic_machine=m68k-rom68k
+		os=-coff
 		;;
 	rm[46]00)
 		basic_machine=mips-siemens
 		;;
 	rtpc | rtpc-*)
 		basic_machine=romp-ibm
 		;;
+	sa29200)
+		basic_machine=a29k-amd
+		os=-udi
+		;;
 	sequent)
 		basic_machine=i386-sequent
 		;;
 	sh)
 		basic_machine=sh-hitachi
 		os=-hms
 		;;
+	sparclite-wrs)
+		basic_machine=sparclite-wrs
+		os=-vxworks
+		;;
 	sps7)
 		basic_machine=m68k-bull
 		os=-sysv2
 		;;
 	spur)
 		basic_machine=spur-unknown
 		;;
+	st2000)
+		basic_machine=m68k-tandem
+		;;
+	stratus)
+		basic_machine=i860-stratus
+		os=-sysv4
+		;;
 	sun2)
 		basic_machine=m68000-sun
 		;;
 	sun2os3)
 		basic_machine=m68000-sun
 		os=-sunos3
 		;;
 	sun2os4)
@@ -580,20 +807,32 @@ case $basic_machine in
 		basic_machine=m68k-sun
 		;;
 	sun4)
 		basic_machine=sparc-sun
 		;;
 	sun386 | sun386i | roadrunner)
 		basic_machine=i386-sun
 		;;
+	sv1)
+		basic_machine=sv1-cray
+		os=-unicos
+		;;
 	symmetry)
 		basic_machine=i386-sequent
 		os=-dynix
 		;;
+	t3e)
+		basic_machine=t3e-cray
+		os=-unicos
+		;;
+	tic54x | c54x*)
+		basic_machine=tic54x-unknown
+		os=-coff
+		;;
 	tx39)
 		basic_machine=mipstx39-unknown
 		;;
 	tx39el)
 		basic_machine=mipstx39el-unknown
 		;;
 	tower | tower-32)
 		basic_machine=m68k-ncr
@@ -601,16 +840,20 @@ case $basic_machine in
 	udi29k)
 		basic_machine=a29k-amd
 		os=-udi
 		;;
 	ultra3)
 		basic_machine=a29k-nyu
 		os=-sym1
 		;;
+	v810 | necv810)
+		basic_machine=v810-nec
+		os=-none
+		;;
 	vaxv)
 		basic_machine=vax-dec
 		os=-sysv
 		;;
 	vms)
 		basic_machine=vax-dec
 		os=-vms
 		;;
@@ -624,30 +867,51 @@ case $basic_machine in
 	vxworks68)
 		basic_machine=m68k-wrs
 		os=-vxworks
 		;;
 	vxworks29k)
 		basic_machine=a29k-wrs
 		os=-vxworks
 		;;
+	w65*)
+		basic_machine=w65-wdc
+		os=-none
+		;;
+	w89k-*)
+		basic_machine=hppa1.1-winbond
+		os=-proelf
+		;;
 	xmp)
 		basic_machine=xmp-cray
 		os=-unicos
 		;;
         xps | xps100)
 		basic_machine=xps100-honeywell
 		;;
+	z8k-*-coff)
+		basic_machine=z8k-unknown
+		os=-sim
+		;;
 	none)
 		basic_machine=none-none
 		os=-none
 		;;
 
 # Here we handle the default manufacturer of certain CPU types.  It is in
 # some cases the only manufacturer, in others, it is the most popular.
+	w89k)
+		basic_machine=hppa1.1-winbond
+		;;
+	op50n)
+		basic_machine=hppa1.1-oki
+		;;
+	op60c)
+		basic_machine=hppa1.1-oki
+		;;
 	mips)
 		if [ x$os = x-linux-gnu ]; then
 			basic_machine=mips-unknown
 		else
 			basic_machine=mips-mips
 		fi
 		;;
 	romp)
@@ -660,28 +924,41 @@ case $basic_machine in
 		basic_machine=vax-dec
 		;;
 	pdp11)
 		basic_machine=pdp11-dec
 		;;
 	we32k)
 		basic_machine=we32k-att
 		;;
-	sparc)
+	sh3 | sh4)
+		basic_machine=sh-unknown
+		;;
+	sparc | sparcv9)
 		basic_machine=sparc-sun
 		;;
         cydra)
 		basic_machine=cydra-cydrome
 		;;
 	orion)
 		basic_machine=orion-highlevel
 		;;
 	orion105)
 		basic_machine=clipper-highlevel
 		;;
+	mac | mpw | mac-mpw)
+		basic_machine=m68k-apple
+		;;
+	pmac | pmac-mpw)
+		basic_machine=powerpc-apple
+		;;
+	c4x*)
+		basic_machine=c4x-none
+		os=-coff
+		;;
 	*)
 		echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
 		exit 1
 		;;
 esac
 
 # Here we canonicalize certain aliases for manufacturers.
 case $basic_machine in
@@ -725,56 +1002,87 @@ case $os in
 	-gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
 	      | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\
 	      | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \
 	      | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
 	      | -aos* \
 	      | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
 	      | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
 	      | -hiux* | -386bsd* | -netbsd* | -openbsd* | -freebsd* | -riscix* \
-	      | -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* \
+	      | -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
 	      | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
 	      | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
-	      | -cygwin32* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
-	      | -mingw32* | -linux-gnu* | -uxpv*)
+	      | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
+	      | -mingw32* | -linux-gnu* | -uxpv* | -beos* | -mpeix* | -udk* \
+	      | -interix* | -uwin* | -rhapsody* | -darwin* | -opened* \
+              | -msvc* \
+	      | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* | -storm-chaos*)
 	# Remember, each alternative MUST END IN *, to match a version number.
 		;;
-	-beos*)
-		os=-beos
+	-qnx*)
+		case $basic_machine in
+		    x86-* | i[34567]86-*)
+			;;
+		    *)
+			os=-nto$os
+			;;
+		esac
+		;;
+	-nto*)
+		os=-nto-qnx
+		;;
+	-sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
+	      | -windows* | -osx | -abug | -netware* | -os9* | -beos* \
+	      | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*)
+		;;
+	-mac*)
+		os=`echo $os | sed -e 's|mac|macos|'`
 		;;
 	-linux*)
 		os=`echo $os | sed -e 's|linux|linux-gnu|'`
 		;;
 	-sunos5*)
 		os=`echo $os | sed -e 's|sunos5|solaris2|'`
 		;;
 	-sunos6*)
 		os=`echo $os | sed -e 's|sunos6|solaris3|'`
 		;;
+	-opened*)
+		os=-openedition
+		;;
+	-wince*)
+		os=-wince
+		;;
 	-osfrose*)
 		os=-osfrose
 		;;
 	-osf*)
 		os=-osf
 		;;
 	-utek*)
 		os=-bsd
 		;;
 	-dynix*)
 		os=-bsd
 		;;
 	-acis*)
 		os=-aos
 		;;
+	-386bsd)
+		os=-bsd
+		;;
 	-ctix* | -uts*)
 		os=-sysv
 		;;
 	-ns2 )
 	        os=-nextstep2
 		;;
+	-nsk*)
+		os=-nsk
+		;;
 	# Preserve the version number of sinix5.
 	-sinix5.*)
 		os=`echo $os | sed -e 's|sinix|sysv|'`
 		;;
 	-sinix*)
 		os=-sysv4
 		;;
 	-triton*)
@@ -790,24 +1098,27 @@ case $os in
 		os=-sysv3
 		;;
 	-sysvr4)
 		os=-sysv4
 		;;
 	# This must come after -sysvr4.
 	-sysv*)
 		;;
+	-ose*)
+		os=-ose
+		;;
+	-es1800*)
+		os=-ose
+		;;
 	-xenix)
 		os=-xenix
 		;;
-	-rhapsody*)
-		;;
-	-qnx*)
-		;;
-	-nto*)
+        -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
+	        os=-mint
 		;;
 	-none)
 		;;
 	*)
 		# Get rid of the `-' at the beginning of $os.
 		os=`echo $os | sed 's/[^-]*-//'`
 		echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2
 		exit 1
@@ -824,16 +1135,19 @@ else
 # that MANUFACTURER isn't an operating system.  Otherwise, code above
 # will signal an error saying that MANUFACTURER isn't an operating
 # system, and we'll never get to this point.
 
 case $basic_machine in
 	*-acorn)
 		os=-riscix1.2
 		;;
+	arm*-rebel)
+		os=-linux
+		;;
 	arm*-semi)
 		os=-aout
 		;;
         pdp11-*)
 		os=-none
 		;;
 	*-dec | vax-*)
 		os=-ultrix4.2
@@ -845,25 +1159,46 @@ case $basic_machine in
 		os=-sunos4.0.2
 		;;
 	m68000-sun)
 		os=-sunos3
 		# This also exists in the configure program, but was not the
 		# default.
 		# os=-sunos4
 		;;
+	m68*-cisco)
+		os=-aout
+		;;
+	mips*-cisco)
+		os=-elf
+		;;
+	mips*-*)
+		os=-elf
+		;;
 	*-tti)	# must be before sparc entry or we get the wrong os.
 		os=-sysv3
 		;;
 	sparc-* | *-sun)
 		os=-sunos4.1.1
 		;;
+	*-be)
+		os=-beos
+		;;
 	*-ibm)
 		os=-aix
 		;;
+	*-wec)
+		os=-proelf
+		;;
+	*-winbond)
+		os=-proelf
+		;;
+	*-oki)
+		os=-proelf
+		;;
 	*-hp)
 		os=-hpux
 		;;
 	*-hitachi)
 		os=-hiux
 		;;
 	i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
 		os=-sysv
@@ -914,19 +1249,31 @@ case $basic_machine in
 		os=-irix
 		;;
         *-siemens)
 		os=-sysv4
 		;;
 	*-masscomp)
 		os=-rtu
 		;;
-	f301-fujitsu)
+	f30[01]-fujitsu | f700-fujitsu)
 		os=-uxpv
 		;;
+	*-rom68k)
+		os=-coff
+		;;
+	*-*bug)
+		os=-coff
+		;;
+	*-apple)
+		os=-macos
+		;;
+	*-atari*)
+		os=-mint
+		;;
 	*)
 		os=-none
 		;;
 esac
 fi
 
 # Here we handle the case where we know the os, and the CPU type, but not the
 # manufacturer.  We pick the logical manufacturer.
@@ -938,44 +1285,67 @@ case $basic_machine in
 				vendor=acorn
 				;;
 			-sunos*)
 				vendor=sun
 				;;
 			-aix*)
 				vendor=ibm
 				;;
+			-beos*)
+				vendor=be
+				;;
 			-hpux*)
 				vendor=hp
 				;;
+			-mpeix*)
+				vendor=hp
+				;;
 			-hiux*)
 				vendor=hitachi
 				;;
 			-unos*)
 				vendor=crds
 				;;
 			-dgux*)
 				vendor=dg
 				;;
 			-luna*)
 				vendor=omron
 				;;
 			-genix*)
 				vendor=ns
 				;;
-			-mvs*)
+			-mvs* | -opened*)
 				vendor=ibm
 				;;
 			-ptx*)
 				vendor=sequent
 				;;
 			-vxsim* | -vxworks*)
 				vendor=wrs
 				;;
 			-aux*)
 				vendor=apple
 				;;
+			-hms*)
+				vendor=hitachi
+				;;
+			-mpw* | -macos*)
+				vendor=apple
+				;;
+			-*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
+				vendor=atari
+				;;
 		esac
 		basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"`
 		;;
 esac
 
 echo $basic_machine$os
+exit 0
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "timestamp='"
+# time-stamp-format: "%:y-%02m-%02d"
+# time-stamp-end: "'"
+# End:
--- a/config/BSD_OS.mk
+++ b/config/BSD_OS.mk
@@ -16,17 +16,17 @@
 #
 
 #
 # Config stuff for BSD/OS Unix.
 #
 
 include $(MOD_DEPTH)/config/UNIX.mk
 
-ifeq (,$(filter-out 1.1 4.0 4.0.1,$(OS_RELEASE)))
+ifeq (,$(filter-out 1.1 4.%,$(OS_RELEASE)))
 CC		= gcc -Wall -Wno-format
 CCC		= g++
 else
 CC		= shlicc2
 CCC		= shlicc2
 endif
 RANLIB		= ranlib
 
@@ -59,17 +59,17 @@ endif
 
 NOSUCHFILE	= /no-such-file
 
 ifeq ($(OS_RELEASE),1.1)
 OS_CFLAGS	+= -D_PR_STAT_HAS_ONLY_ST_ATIME -D_PR_NEED_H_ERRNO
 else
 OS_CFLAGS	+= -DHAVE_DLL -DUSE_DLFCN -D_PR_STAT_HAS_ST_ATIMESPEC
 OS_LIBS		= -ldl
-ifeq (,$(filter-out 4.0 4.0.1,$(OS_RELEASE)))
+ifeq (,$(filter-out 4.%,$(OS_RELEASE)))
 MKSHLIB		= $(CC) $(DSO_LDOPTS)
 DSO_CFLAGS	= -fPIC
 DSO_LDOPTS	= -shared -Wl,-soname,$(@:$(OBJDIR)/%.so=%.so)
 else
 MKSHLIB		= $(LD) $(DSO_LDOPTS)
 DSO_LDOPTS	= -r
 endif
 endif
--- a/config/BeOS.mk
+++ b/config/BeOS.mk
@@ -25,16 +25,17 @@
 
 DEFINES			+= 
 XP_DEFINE		= -DXP_BEOS
 
 OBJ_SUFFIX              = o
 LIB_SUFFIX              = a
 DLL_SUFFIX              = so
 AR                      = ar cr $@
+STRIP			= strip
 
 ifdef BUILD_OPT
 DEFINES                 = -UDEBUG -DNDEBUG
 OBJDIR_TAG              = _OPT
 else
 DEFINES                 = -DDEBUG -UNDEBUG
 OBJDIR_TAG              = _DBG
 endif
--- a/config/Linux.mk
+++ b/config/Linux.mk
@@ -42,22 +42,20 @@ ifeq ($(CLASSIC_NSPR),1)
 IMPL_STRATEGY		= _EMU
 DEFINES			+= -D_PR_LOCAL_THREADS_ONLY
 else
 USE_PTHREADS		= 1
 IMPL_STRATEGY		= _PTH
 DEFINES			+= -D_REENTRANT
 endif
 
-USE_IPV6 = 1
-
 ifeq (86,$(findstring 86,$(OS_TEST)))
 CPU_ARCH		:= x86
 else
-ifeq (,$(filter-out armv4l sa110,$(OS_TEST)))
+ifeq (,$(filter-out arm% sa110,$(OS_TEST)))
 CPU_ARCH		:= arm
 else
 CPU_ARCH		:= $(OS_TEST)
 endif
 endif
 CPU_ARCH_TAG		= _$(CPU_ARCH)
 
 CC			= gcc
@@ -96,16 +94,18 @@ endif
 
 #
 # Linux 2.x has shared libraries.
 #
 
 MKSHLIB			= $(LD) $(DSO_LDOPTS) -soname $(notdir $@)
 ifdef BUILD_OPT
 OPTIMIZER		= -O2
+#   invoke 'strip' on *.so files in optimized builds
+STRIP = strip
 endif
 
 ######################################################################
 # Overrides for defaults in config.mk (or wherever)
 ######################################################################
 
 ######################################################################
 # Other
--- a/config/Makefile.in
+++ b/config/Makefile.in
@@ -22,23 +22,32 @@ topsrcdir	= @top_srcdir@
 srcdir		= @srcdir@
 VPATH		= @srcdir@
 
 include $(MOD_DEPTH)/config/autoconf.mk
 
 # Indicate that this directory builds build tools.
 INTERNAL_TOOLS	= 1
 
+# autoconf.mk must be deleted last (from the top-level directory)
+# because it is included by every makefile.
+DIST_GARBAGE	= nsprincl.mk nsprincl.sh
+
 include $(topsrcdir)/config/config.mk
 
-CSRCS	= nsinstall.c now.c
+CSRCS	= now.c
 
+# This version hasn't been ported for us; the one in mozilla/config has
+ifneq ($(OS_ARCH),OS2)
+CSRCS  += nsinstall.c
+ 
 PLSRCS	= nfspwd.pl
+endif
 
-ifeq ($(OS_ARCH), WINNT)
+ifeq (,$(filter-out WINNT OS2,$(OS_ARCH)))
 PROG_SUFFIX = .exe
 else
 PROG_SUFFIX =
 endif
 
 # Temporary workaround to disable the generation of
 # library build time because now.c uses the 'long long'
 # data type that's not available on some platforms.
@@ -64,30 +73,37 @@ ifeq ($(OS_ARCH), IRIX)
 endif
 
 ifeq ($(OS_ARCH), HP-UX)
     ifeq ($(USE_64),1)
         XLDOPTS += +DA2.0W
     endif
 endif
 
-ifdef XP_OS2_EMX
+ifeq ($(MOZ_OS2_TOOLS),EMX)
+XCFLAGS = $(OS_EXE_CFLAGS)
+ifeq ($(MOZ_OS2_EMX_OBJECTFORMAT),OMF)
+XLDOPTS = -Zlinker /PM:VIO
+endif
+endif
+
+ifeq ($(MOZ_OS2_TOOLS),PGCC)
 XCFLAGS = $(OS_EXE_CFLAGS)
 XLDOPTS = -Zlinker /PM:VIO
 endif
 
 ifeq ($(MOZ_OS2_TOOLS),VACPP)
 OS_CFLAGS = $(OS_EXE_CFLAGS)
 endif
 
 include $(topsrcdir)/config/rules.mk
 
 PROGS	= $(OBJDIR)/now$(PROG_SUFFIX)
 
-ifeq ($(OS_ARCH),WINNT)
+ifeq (,$(filter-out OS2 WINNT,$(OS_ARCH)))
 TARGETS = $(PROGS)
 else
 PROGS	+= $(OBJDIR)/nsinstall$(PROG_SUFFIX)
 TARGETS = $(PROGS) $(PLSRCS:.pl=)
 endif
 
 OUTOPTION = -o # end of the line
 ifeq (,$(filter-out WINNT WIN95,$(OS_TARGET)))
--- a/config/NTO.mk
+++ b/config/NTO.mk
@@ -50,25 +50,25 @@ LD			 = $(CC)
 CCC			 = $(CC)
 
 # Old Flags  -DNO_REGEX   -DSTRINGS_ALIGNED
 
 OS_CFLAGS	 = -Wc,-Wall -Wc,-Wno-parentheses -DNTO  \
 			   -D_QNX_SOURCE -DHAVE_POINTER_LOCALTIME_R -shared
 
 COMPILER_TAG = _qcc
-MKSHLIB		 = qcc -Vgcc_ntox86 -shared -Wl,-h$(@:$(OBJDIR)/%.so=%.so) -g2 -M
+MKSHLIB		 = qcc -Vgcc_ntox86 -shared -Wl,-h$(@:$(OBJDIR)/%.so=%.so) -M
 
 RANLIB		 = ranlib
 G++INCLUDES	 =
 OS_LIBS		 =
 EXTRA_LIBS  = -lsocket
 
 ifdef BUILD_OPT
-OPTIMIZER = -O2
+OPTIMIZER = -O1
 else
-OPTIMIZER = -O2 -gdwarf-2
+OPTIMIZER = -O1 -gstabs
 endif
 
 NOSUCHFILE	= /no-such-file
 
 GARBAGE		+= *.map
 
--- a/config/NetBSD.mk
+++ b/config/NetBSD.mk
@@ -20,16 +20,20 @@
 #
 
 include $(MOD_DEPTH)/config/UNIX.mk
 
 CC			= gcc
 CCC			= g++
 RANLIB			= ranlib
 
+ifndef OBJECT_FMT
+OBJECT_FMT		:= $(shell if echo __ELF__ | $${CC:-cc} -E - | grep -q __ELF__ ; then echo a.out ; else echo ELF ; fi)
+endif
+
 OS_REL_CFLAGS		=
 ifeq (86,$(findstring 86,$(OS_TEST)))
 CPU_ARCH		= x86
 else
 CPU_ARCH		= $(OS_TEST)
 endif
 
 OS_CFLAGS		= $(DSO_CFLAGS) $(OS_REL_CFLAGS) -ansi -Wall -pipe -DNETBSD -DHAVE_STRERROR -DHAVE_BSD_FLOCK
@@ -39,30 +43,25 @@ OS_LIBS			= -lc_r
 # XXX probably should define _THREAD_SAFE too.
 else
 OS_LIBS			= -lc
 DEFINES			+= -D_PR_LOCAL_THREADS_ONLY
 endif
 
 ARCH			= netbsd
 
+ifeq ($(OBJECT_FMT),ELF)
+DLL_SUFFIX		= so
+else
 DLL_SUFFIX		= so.1.0
+endif
 
-DSO_CFLAGS		= -fPIC
+DSO_CFLAGS		= -fPIC -DPIC
 DSO_LDFLAGS		=
-DSO_LDOPTS		= -Bshareable
-ifeq ($(OS_TEST),alpha)
-DSO_LDOPTS		= -shared
-endif
-ifeq ($(OS_TEST),mips)
-DSO_LDOPTS		= -shared
-endif
-ifeq ($(OS_TEST),pmax)  
-DSO_LDOPTS		= -shared
-endif
+DSO_LDOPTS		= -x -shared
 
 ifdef LIBRUNPATH
 DSO_LDOPTS		+= -R$(LIBRUNPATH)
 endif
 
 MKSHLIB			= $(LD) $(DSO_LDOPTS)
 
 G++INCLUDES		= -I/usr/include/g++
--- a/config/OS2.mk
+++ b/config/OS2.mk
@@ -40,40 +40,41 @@ endif
 
 ifeq ($(XP_OS2_EMX),1)
 MOZ_EMXTAG = $(subst .,,$(MOZ_OS2_EMX_OBJECTFORMAT))
 endif
 
 #
 # On OS/2 we proudly support gbash...
 #
-SHELL = GBASH.EXE
+SHELL := GBASH.EXE
 
 CC			= icc -q -DXP_OS2 -N10
 CCC			= icc -q -DXP_OS2 -DOS2=4 -N10
-LINK			= ilink
-AR			= ilib /noignorecase /nologo /Out:$(subst /,\\,$@)
+LINK			= -ilink
+AR			= -ilib /noignorecase /nologo /Out:$(subst /,\\,$@)
 RANLIB 			= @echo RANLIB
 BSDECHO 		= @echo BSDECHO
+STRIP			= @echo STRIP
 NSINSTALL 		= nsinstall
 INSTALL			= $(NSINSTALL)
 MAKE_OBJDIR 		= if test ! -d $(OBJDIR); then mkdir $(OBJDIR); fi
 IMPLIB 			= implib -nologo -noignorecase
 FILTER 			= cppfilt -b -p -q
 RC 			= rc.exe
 
 GARBAGE =
 
 XP_DEFINE 		= -DXP_PC
 LIB_SUFFIX 		= lib
 DLL_SUFFIX 		= dll
 OBJ_SUFFIX		= obj
 
-OS_CFLAGS     		= -W3 -Wcnd- -gm -gd+ -sd- -su4 -ge-
-OS_EXE_CFLAGS 		= -W3 -Wcnd- -gm -gd+ -sd- -su4 
+OS_CFLAGS     		= -W3 -Wcnd- -gm -gd+ -sd- -su4 -ge- -Mp
+OS_EXE_CFLAGS 		= -W3 -Wcnd- -gm -gd+ -sd- -su4 -Mp
 AR_EXTRA_ARGS 		= 
 
 ifdef BUILD_OPT
 OPTIMIZER		= -O+ -Oi 
 DEFINES 		= -UDEBUG -U_DEBUG -DNDEBUG
 DLLFLAGS		= -DLL -OUT:$@ -MAP:$(@:.dll=.map)
 EXEFLAGS    		= -PMTYPE:VIO -OUT:$@ -MAP:$(@:.exe=.map) -nologo -NOE
 OBJDIR_TAG 		= _OPT
--- a/config/OSF1.mk
+++ b/config/OSF1.mk
@@ -19,17 +19,17 @@
 # Config stuff for DEC OSF/1
 #
 
 #
 # The Bourne shell (sh) on OSF1 doesn't handle "set -e" correctly,
 # which we use to stop LOOP_OVER_DIRS submakes as soon as any
 # submake fails.  So we use the Korn shell instead.
 #
-SHELL			= /usr/bin/ksh
+SHELL			:= /usr/bin/ksh
 
 include $(MOD_DEPTH)/config/UNIX.mk
 
 #
 # XXX
 # Temporary define for the Client; to be removed when binary release is used
 #
 ifdef MOZILLA_CLIENT
--- a/config/OpenBSD.mk
+++ b/config/OpenBSD.mk
@@ -30,26 +30,26 @@ ifeq (86,$(findstring 86,$(OS_TEST)))
 CPU_ARCH               = x86
 else
 CPU_ARCH               = $(OS_TEST)
 endif
 
 OS_CFLAGS              = $(DSO_CFLAGS) $(OS_REL_CFLAGS) -ansi -Wall -pipe $(THREAD_FLAG) -DOPENBSD -DHAVE_STRERROR -DHAVE_BSD_FLOCK
 
 ifeq ($(USE_PTHREADS),1)
-OS_LIBS                        = -lc_r
 THREAD_FLAG		+= -pthread
 # XXX probably should define _THREAD_SAFE too.
 else
-OS_LIBS                        = -lc
 DEFINES                        += -D_PR_LOCAL_THREADS_ONLY
 endif
 
 ARCH                   = openbsd
 
+DLL_SUFFIX             = so.1.0
+
 DSO_CFLAGS             = -fPIC
 DSO_LDFLAGS            =
 DSO_LDOPTS             = -Bshareable
 ifeq ($(OS_TEST),alpha)
 DSO_LDOPTS             = -shared
 endif
 ifeq ($(OS_TEST),mips)
 DSO_LDOPTS             = -shared
--- a/config/Rhapsody.mk
+++ b/config/Rhapsody.mk
@@ -16,22 +16,29 @@
 #
 
 #
 # Config stuff for Rhapsody
 #
 
 include $(MOD_DEPTH)/config/UNIX.mk
 
+#
+# The default implementation strategy for Rhapsody is pthreads.
+#
+ifeq ($(CLASSIC_NSPR),1)
+IMPL_STRATEGY   = _EMU
+DEFINES         += -D_PR_LOCAL_THREADS_ONLY
+else
+USE_PTHREADS    = 1
+IMPL_STRATEGY   = _PTH
+endif
+
 CC              = cc
-ifeq ($(OS_RELEASE),5.0)
-CCC             = cc++
-else
 CCC             = c++
-endif
 RANLIB			= ranlib
 
 ifeq (86,$(findstring 86,$(OS_TEST)))
 OS_REL_CFLAGS   = -mno-486 -Di386
 CPU_ARCH        = i386
 else
 OS_REL_CFLAGS   = -Dppc
 CPU_ARCH		= ppc
@@ -44,18 +51,16 @@ endif
 # or it may be a declaration of a symbol defined in another file:
 #     extern int x;
 # Use the -fno-common option to force all commons to become true
 # definitions so that the linker can catch multiply-defined symbols.
 # Also, common symbols are not allowed with Rhapsody dynamic libraries.
 
 OS_CFLAGS		= $(DSO_CFLAGS) $(OS_REL_CFLAGS) -Wmost -fno-common -pipe -DRHAPSODY -DHAVE_STRERROR -DHAVE_BSD_FLOCK
 
-DEFINES			+= -D_PR_LOCAL_THREADS_ONLY
-
 ARCH			= rhapsody
 
 # May override this with -bundle to create a loadable module.
 DSO_LDOPTS		= -dynamiclib -compatibility_version 1 -current_version 1 -all_load
 
 MKSHLIB			= $(CC) -arch $(CPU_ARCH) $(DSO_LDOPTS)
 DLL_SUFFIX		= dylib
 
--- a/config/UNIX.mk
+++ b/config/UNIX.mk
@@ -16,16 +16,17 @@
 #
 
 PR_UNIXOS	= 1
 XP_DEFINE	= -DXP_UNIX
 OBJ_SUFFIX	= o
 LIB_SUFFIX	= a
 DLL_SUFFIX	= so
 AR		= ar cr $@
+STRIP		= true
 
 ifdef BUILD_OPT
 OPTIMIZER	= -O
 DEFINES		= -UDEBUG -DNDEBUG
 OBJDIR_TAG	= _OPT
 else
 OPTIMIZER	= -g
 DEFINES		= -DDEBUG -UNDEBUG -DDEBUG_$(shell whoami)
--- a/config/WIN32.mk
+++ b/config/WIN32.mk
@@ -21,25 +21,26 @@
 #
 
 #
 # Client build: make sure we use the shmsdos.exe under $(MOZ_TOOLS).
 # $(MOZ_TOOLS_FLIPPED) is $(MOZ_TOOLS) with all the backslashes
 # flipped, so that gmake won't interpret them as escape characters.
 #
 ifdef PR_CLIENT_BUILD_WINDOWS
-SHELL = $(MOZ_TOOLS_FLIPPED)/bin/shmsdos.exe
+SHELL := $(MOZ_TOOLS_FLIPPED)/bin/shmsdos.exe
 endif
 
 CC = cl
 CCC = cl
 LINK = link
 AR = lib -NOLOGO -OUT:"$@"
 RANLIB = echo
 BSDECHO = echo
+STRIP = echo
 NSINSTALL = nsinstall
 INSTALL	= $(NSINSTALL)
 define MAKE_OBJDIR
 if test ! -d $(@D); then rm -rf $(@D); $(NSINSTALL) -D $(@D); fi
 endef
 RC = rc.exe
 
 GARBAGE = $(OBJDIR)/vc20.pdb $(OBJDIR)/vc40.pdb
@@ -48,24 +49,17 @@ XP_DEFINE = -DXP_PC
 OBJ_SUFFIX = obj
 LIB_SUFFIX = lib
 DLL_SUFFIX = dll
 
 OS_CFLAGS = -W3 -nologo -GF -Gy
 
 ifdef BUILD_OPT
 OS_CFLAGS += -MD
-# The -O2 optimization of MSVC 6.0 SP3 appears to generate
-# code that is unsafe for our use of fibers and static thread
-# local storage.  We temporarily work around this problem by
-# turning off global optimizations (-Og).
 OPTIMIZER = -O2
-ifeq ($(OS_TARGET),WINNT)
-OPTIMIZER += -Og-
-endif
 DEFINES = -UDEBUG -U_DEBUG -DNDEBUG
 DLLFLAGS = -OUT:"$@"
 OBJDIR_TAG = _OPT
 
 # Add symbolic information for use by a profiler
 ifdef MOZ_PROFILE
 OPTIMIZER += -Z7
 DLLFLAGS += -DEBUG -DEBUGTYPE:CV
--- a/config/arch.mk
+++ b/config/arch.mk
@@ -45,37 +45,41 @@ endif
 ifeq ($(OS_ARCH),UNIX_SV)
 ifneq ($(findstring NCR,$(shell grep NCR /etc/bcheckrc | head -1 )),)
 OS_ARCH		:= NCR
 else
 OS_ARCH		:= UNIXWARE
 OS_RELEASE	:= $(shell uname -v)
 endif
 endif
+ifeq ($(OS_ARCH),Mac OS)
+OS_ARCH		:= Rhapsody
+endif
 ifeq ($(OS_ARCH),ncr)
 OS_ARCH		:= NCR
 endif
 # This is the only way to correctly determine the actual OS version on NCR boxes.
 ifeq ($(OS_ARCH),NCR)
 OS_RELEASE	:= $(shell awk '{print $$3}' /etc/.relid | sed 's/^\([0-9]\)\(.\)\(..\)\(.*\)$$/\2.\3/')
 endif
-ifeq ($(OS_ARCH),procnto)
-OS_ARCH      := NTO
-OS_RELEASE := _$(OS_TEST)$(OS_RELEASE)
-endif
 ifeq ($(OS_ARCH),UNIX_System_V)
 OS_ARCH		:= NEC
 endif
 ifneq (,$(findstring POSIX_for_OpenVMS,$(OS_ARCH)))
 OS_ARCH		:= OpenVMS
 CPU_ARCH	:= $(shell uname -Wh)
 OS_RELEASE	:= $(shell uname -v)
 endif
 ifeq ($(OS_ARCH),QNX)
-OS_RELEASE	:= $(shell uname -v | sed 's/^\([0-9]\)\([0-9]*\)$$/\1.\2/')
+	ifeq ($(OS_RELEASE),6.00)
+		OS_ARCH := NTO
+		OS_RELEASE := _$(OS_TEST)$(OS_RELEASE)
+	else
+		OS_RELEASE := $(shell uname -v | sed 's/^\([0-9]\)\([0-9]*\)$$/\1.\2/')
+	endif
 endif
 ifeq ($(OS_ARCH),SCO_SV)
 OS_ARCH		:= SCOOS
 OS_RELEASE	:= 5.0
 endif
 ifeq ($(OS_ARCH),SINIX-N)
 OS_ARCH		:= SINIX
 endif
--- a/config/autoconf.mk.in
+++ b/config/autoconf.mk.in
@@ -1,24 +1,35 @@
 
+INCLUDED_AUTOCONF_MK = 1
 USE_AUTOCONF	= 1
 MOZILLA_CLIENT	= @MOZILLA_CLIENT@
 DIST		= @prefix@
-OBJDIR_NAME	= .
-OBJDIR		= .
+prefix		= @prefix@
+exec_prefix	= @exec_prefix@
+bindir		= @bindir@
+includedir	= @includedir@
+libdir		= @libdir@
+
+OBJDIR_NAME	= @OBJDIR_NAME@
+OBJDIR		= @OBJDIR@
 OBJ_SUFFIX	= @OBJ_SUFFIX@
 LIB_SUFFIX	= @LIB_SUFFIX@
 DLL_SUFFIX	= @DLL_SUFFIX@
 MOD_VERSION	= @NSPR_VERSION@
 MOD_NAME	= @NSPR_MODNAME@
 
+CROSS_COMPILE	= @CROSS_COMPILE@
+BUILD_OPT	= @MOZ_OPTIMIZE@
+
 USE_CPLUS	= @USE_CPLUS@
 USE_IPV6	= @USE_IPV6@
 USE_N32		= @USE_N32@
 USE_64		= @USE_64@
+GC_LEAK_DETECTOR = @GC_LEAK_DETECTOR@
 
 USE_PTHREADS	= @USE_PTHREADS@
 USE_BTHREADS	= @USE_BTHREADS@
 PTHREADS_USER	= @USE_USER_PTHREADS@
 CLASSIC_NSPR	= @USE_NSPR_THREADS@
 
 AS		= @AS@
 ASFLAGS		= @ASFLAGS@
@@ -26,39 +37,45 @@ CC		= @CC@
 CCC		= @CXX@
 AR		= @AR@
 AR_FLAGS	= @AR_FLAGS@
 LD		= @LD@
 RANLIB		= @RANLIB@
 PERL		= @PERL@
 DLLTOOL		= @DLLTOOL@
 WINDRES		= @WINDRES@
-RC		= $(WINDRES)
+RC		= @RC@
+STRIP		= @STRIP@
+NSINSTALL	= @NSINSTALL@
 
 OS_CFLAGS	= @CFLAGS@ $(DSO_CFLAGS)
 OS_CXXFLAGS	= @CXXFLAGS@ $(DSO_CFLAGS)
 OS_LIBS         = @OS_LIBS@
 OS_LDFLAGS	= @LDFLAGS@
+OS_DLLFLAGS	= @OS_DLLFLAGS@
+DLLFLAGS	= @DLLFLAGS@
+OPTIMIZER	= @OPTIMIZER@
 
 MKSHLIB		= @MKSHLIB@
 DSO_CFLAGS	= @DSO_CFLAGS@
 DSO_LDOPTS	= @DSO_LDOPTS@
 
 RESOLVE_LINK_SYMBOLS = @RESOLVE_LINK_SYMBOLS@
 
 HOST_CC		= @HOST_CC@
 HOST_CFLAGS	= @HOST_CFLAGS@
 
 DEFINES		= @DEFINES@ @DEFS@
 
 MDCPUCFG_H	= @MDCPUCFG_H@
-MOZ_TARGET	= @MOZ_TARGET@
+MOZ_WIN32_TARGET= @MOZ_WIN32_TARGET@
 PR_MD_CSRCS	= @PR_MD_CSRCS@
 PR_MD_ASFILES	= @PR_MD_ASFILES@
 PR_MD_ARCH_DIR	= @PR_MD_ARCH_DIR@
+CPU_ARCH	= @CPU_ARCH@
 
 OS_TARGET	= @OS_TARGET@
 OS_ARCH		= @OS_ARCH@
 OS_RELEASE	= @OS_RELEASE@
 OS_TEST		= @OS_TEST@
 
 NOSUCHFILE	= @NOSUCHFILE@
 AIX_LINK_OPTS	= @AIX_LINK_OPTS@
--- a/config/config.mk
+++ b/config/config.mk
@@ -49,37 +49,51 @@ CFLAGS		= $(CC_ONLY_FLAGS) $(OPTIMIZER) 
 CCCFLAGS	= $(CCC_ONLY_FLAGS) $(OPTIMIZER) $(OS_CFLAGS)\
 		  $(XP_DEFINE) $(DEFINES) $(INCLUDES) $(XCFLAGS)
 # For purify
 NOMD_CFLAGS	= $(CC_ONLY_FLAGS) $(OPTIMIZER) $(NOMD_OS_CFLAGS)\
 		  $(XP_DEFINE) $(DEFINES) $(INCLUDES) $(XCFLAGS)
 NOMD_CCFLAGS	= $(CCC_ONLY_FLAGS) $(OPTIMIZER) $(NOMD_OS_CFLAGS)\
 		  $(XP_DEFINE) $(DEFINES) $(INCLUDES) $(XCFLAGS)
 
-NSINSTALL	= $(MOD_DEPTH)/config/$(OBJDIR_NAME)/nsinstall
+LDFLAGS		= $(OS_LDFLAGS)
+
+define MAKE_OBJDIR
+if test ! -d $(@D); then rm -rf $(@D); $(NSINSTALL) -D $(@D); fi
+endef
 
+LINK_DLL	= $(LD) $(OS_DLLFLAGS) $(DLLFLAGS)
+
+ifneq (,$(filter WINNT OS2, $(OS_ARCH)))
+INSTALL		= $(NSINSTALL)
+else
 ifeq ($(NSDISTMODE),copy)
 # copy files, but preserve source mtime
 INSTALL		= $(NSINSTALL) -t
 else
 ifeq ($(NSDISTMODE),absolute_symlink)
 # install using absolute symbolic links
 INSTALL		= $(NSINSTALL) -L `$(NFSPWD)`
 else
 # install using relative symbolic links
 INSTALL		= $(NSINSTALL) -R
 endif
 endif
+endif # WINNT || OS2
 
 ifdef BUILD_DEBUG_GC
 DEFINES		+= -DDEBUG_GC
 endif
 
 GARBAGE		+= $(DEPENDENCIES) core $(wildcard core.[0-9]*)
 
+ifdef USE_AUTOCONF
+DIST_GARBAGE += Makefile
+endif
+
 DEFINES += -DFORCE_PR_LOG
 
 ifeq ($(_PR_NO_CLOCK_TIMER),1)
 DEFINES += -D_PR_NO_CLOCK_TIMER
 endif
 
 ifeq ($(USE_PTHREADS), 1)
 DEFINES += -D_PR_PTHREADS -UHAVE_CVAR_BUILT_ON_SEM
@@ -146,16 +160,23 @@ include $(MOD_DEPTH)/config/$(OS_TARGET)
 BUILD		= $(OBJDIR_NAME)
 OBJDIR		= $(OBJDIR_NAME)
 DIST		= $(NSDEPTH)/dist/$(OBJDIR_NAME)
 ifeq ($(MOZ_BITS),16)
 MOZ_INCL	= $(NSDEPTH)/dist/public/win16
 MOZ_DIST	= $(NSDEPTH)/dist/WIN16D_D.OBJ
 endif
 
+# if not using autoconf, set these values accordingly
+prefix		= $(DIST)
+exec_prefix	= $(prefix)
+bindir		= $(prefix)/bin
+includedir	= $(prefix)/include
+libdir		= $(prefix)/lib
+
 VPATH		= $(OBJDIR)
 DEPENDENCIES	= $(OBJDIR)/.md
 
 ifdef BUILD_DEBUG_GC
 DEFINES		+= -DDEBUG_GC
 endif
 
 GARBAGE		+= $(DEPENDENCIES) core $(wildcard core.[0-9]*)
@@ -179,16 +200,20 @@ endif
 ifeq ($(PTHREADS_USER), 1)
 OS_CFLAGS += -DPTHREADS_USER -UHAVE_CVAR_BUILT_ON_SEM
 endif
 
 ifeq ($(USE_IPV6),1)
 OS_CFLAGS += -D_PR_INET6
 endif
 
+ifdef GC_LEAK_DETECTOR
+OS_CFLAGS += -DGC_LEAK_DETECTOR
+endif
+
 ####################################################################
 #
 # Configuration for the release process
 #
 ####################################################################
 
 MDIST = /m/dist
 ifeq ($(OS_ARCH),WINNT)
--- a/config/nsinstall.c
+++ b/config/nsinstall.c
@@ -36,17 +36,19 @@
 #include <errno.h>
 #include <stdarg.h>
 #ifdef USE_REENTRANT_LIBC
 #include "libc_r.h"
 #endif /* USE_REENTRANT_LIBC */
 
 #include "pathsub.h"
 
+#ifndef HAVE_LCHOWN
 #define HAVE_LCHOWN
+#endif
 
 #if defined(AIX) || defined(BSDI) || defined(HPUX) || defined(LINUX) \
     || defined(SUNOS4) || defined(SCO) || defined(UNIXWARE) \
     || defined(RHAPSODY) || defined(NEXTSTEP) || defined(QNX) \
     || defined(BEOS) || defined(VMS)
 #undef HAVE_LCHOWN
 #endif
 
--- a/config/rules.mk
+++ b/config/rules.mk
@@ -56,23 +56,25 @@ ifndef srcdir
 srcdir=.
 endif
 
 ifndef NSPR_CONFIG_MK
 include $(topsrcdir)/config/config.mk
 endif
 
 ifdef USE_AUTOCONF
+ifdef CROSS_COMPILE
 ifdef INTERNAL_TOOLS
 CC=$(HOST_CC)
 CCC=$(HOST_CXX)
 CFLAGS=$(HOST_CFLAGS)
 CXXFLAGS=$(HOST_CXXFLAGS)
 endif
 endif
+endif
 
 #
 # This makefile contains rules for building the following kinds of
 # libraries:
 # - LIBRARY: a static (archival) library
 # - SHARED_LIBRARY: a shared (dynamic link) library
 # - IMPORT_LIBRARY: an import library, used only on Windows and OS/2
 #
@@ -165,39 +167,41 @@ LOOP_OVER_DIRS		=					\
 		else						\
 			echo "Skipping non-directory $$d...";	\
 		fi;						\
 	done
 endif
 
 ################################################################################
 
-all:: export libs install
+all:: export
 
 export::
 	+$(LOOP_OVER_DIRS)
 
-libs::
-	+$(LOOP_OVER_DIRS)
+libs:: export
 
-install::
-	+$(LOOP_OVER_DIRS)
+install:: export
 
 clean::
 	rm -rf $(OBJS) so_locations $(NOSUCHFILE) $(GARBAGE)
 	+$(LOOP_OVER_DIRS)
 
 clobber::
 	rm -rf $(OBJS) $(TARGETS) $(filter-out . ..,$(OBJDIR)) $(GARBAGE) so_locations $(NOSUCHFILE)
 	+$(LOOP_OVER_DIRS)
 
 realclean clobber_all::
 	rm -rf $(wildcard *.OBJ *.OBJD) dist $(ALL_TRASH)
 	+$(LOOP_OVER_DIRS)
 
+distclean::
+	rm -rf $(wildcard *.OBJ *.OBJD) dist $(ALL_TRASH) $(DIST_GARBAGE)
+	+$(LOOP_OVER_DIRS)
+
 release:: export
 ifdef RELEASE_BINS
 	@echo "Copying executable programs and scripts to release directory"
 	@if test -z "$(BUILD_NUMBER)"; then \
 		echo "BUILD_NUMBER must be defined"; \
 		false; \
 	else \
 		true; \
@@ -258,16 +262,19 @@ ifeq ($(OS_ARCH),WINNT)
 	$(CC) $(OBJS) -Fe$@ -link $(LDFLAGS) $(OS_LIBS) $(EXTRA_LIBS)
 else
 ifeq ($(MOZ_OS2_TOOLS),VACPP)
 	$(CC) $(OBJS) -Fe$@ $(LDFLAGS) $(OS_LIBS) $(EXTRA_LIBS)
 else
 	$(CC) -o $@ $(CFLAGS) $(OBJS) $(LDFLAGS)
 endif
 endif
+ifdef BUILD_OPT
+	$(STRIP) $@
+endif
 
 $(LIBRARY): $(OBJS)
 	@$(MAKE_OBJDIR)
 	rm -f $@
 ifeq ($(MOZ_OS2_TOOLS),VACPP)
 	$(AR) $(subst /,\\,$(OBJS)) $(AR_EXTRA_ARGS)
 else
 ifdef USE_AUTOCONF
@@ -286,19 +293,16 @@ endif
 ifeq ($(OS_TARGET), OS2)
 $(IMPORT_LIBRARY): $(SHARED_LIBRARY)
 	$(IMPLIB) $@ $(SHARED_LIBRARY).def
 endif
     
 $(SHARED_LIBRARY): $(OBJS)
 	@$(MAKE_OBJDIR)
 	rm -f $@
-ifdef USE_AUTOCONF
-	$(MKSHLIB) $(OBJS) $(EXTRA_LIBS) $(OS_LIBS)
-else
 ifeq ($(OS_ARCH)$(OS_RELEASE), AIX4.1)
 	echo "#!" > $(OBJDIR)/lib$(LIBRARY_NAME)_syms
 	nm -B -C -g $(OBJS) \
 		| awk '/ [T,D] / {print $$3}' \
 		| sed -e 's/^\.//' \
 		| sort -u >> $(OBJDIR)/lib$(LIBRARY_NAME)_syms
 	$(LD) $(XCFLAGS) -o $@ $(OBJS) -bE:$(OBJDIR)/lib$(LIBRARY_NAME)_syms \
 		-bM:SRE -bnoentry $(OS_LIBS) $(EXTRA_LIBS)
@@ -338,32 +342,38 @@ ifeq ($(OS_TARGET), OpenVMS)
 	@if test ! -f $(OBJDIR)/VMSuni.opt; then \
 	    echo "Creating universal symbol option file $(OBJDIR)/VMSuni.opt";\
 	    create_opt_uni $(OBJS); \
 	    mv VMSuni.opt $(OBJDIR); \
 	fi
 	$(MKSHLIB) -o $@ $(OBJS) $(EXTRA_LIBS) $(OS_LIBS) $(OBJDIR)/VMSuni.opt
 	@echo "`translate $@`" > $(@:.$(DLL_SUFFIX)=.vms)
 else	# OpenVMS
+ifdef USE_AUTOCONF
+	$(MKSHLIB) $(OBJS) $(EXTRA_LIBS)
+else
 	$(MKSHLIB) -o $@ $(OBJS) $(EXTRA_LIBS) $(OS_LIBS)
+endif   # USE_AUTOCONF
 endif	# OpenVMS
 endif   # OS2
 endif	# WINNT
 endif	# AIX 4.1
-endif   # USE_AUTOCONF
+ifdef BUILD_OPT
+	$(STRIP) $@
+endif
 
 
 ifeq (,$(filter-out WINNT OS2,$(OS_ARCH)))
 $(RES): $(RESNAME)
 	@$(MAKE_OBJDIR)
 ifeq ($(OS_TARGET),OS2)
-	$(RC) -DOS2 -r $(RESNAME) $(RES)
+	$(RC) -DOS2 -r $< $@
 else
 # The resource compiler does not understand the -U option.
-	$(RC) $(filter-out -U%,$(DEFINES)) $(INCLUDES) -Fo$(RES) $(RESNAME)
+	$(RC) $(filter-out -U%,$(DEFINES)) $(INCLUDES) -Fo$@ $<
 endif
 	@echo $(RES) finished
 endif
 
 $(OBJDIR)/%.$(OBJ_SUFFIX): %.cpp
 	@$(MAKE_OBJDIR)
 ifeq ($(OS_ARCH), WINNT)
 	$(CCC) -Fo$@ -c $(CCCFLAGS) $<
--- a/config/win16.mk
+++ b/config/win16.mk
@@ -50,16 +50,17 @@
 
 CC = wcc
 CCC = wcl
 LINK = wlink
 AR = wlib -q $@
 RC = wrc.exe /r /dWIN16=1 /bt=windows
 RANLIB = echo
 BSDECHO = echo
+STRIP = echo
 NSINSTALL = nsinstall
 INSTALL	= $(NSINSTALL)
 MAKE_OBJDIR = mkdir $(OBJDIR)
 
 XP_DEFINE = -DXP_PC
 OBJ_SUFFIX = obj
 LIB_SUFFIX = lib
 DLL_SUFFIX = dll
--- a/configure
+++ b/configure
@@ -10,25 +10,26 @@
 # Defaults:
 ac_help=
 ac_default_prefix=/usr/local
 # Any additions from configure.in:
 ac_default_prefix=\${MOD_DEPTH}/dist
 ac_help="$ac_help
   --with-mozilla          Compile NSPR with Mozilla support"
 ac_help="$ac_help
-  --enable-optimize       Enable code optimizations"
+  --enable-optimize(=flag) Enable code optimizations (flag, ie. -O2) "
 ac_help="$ac_help
   --disable-debug         Do not compile in debugging symbols"
 ac_help="$ac_help
   --disable-shared        Do not compile into shared libraries"
 ac_help="$ac_help
-  --enable-target=\$t      Turn on features for target \$t when build has multiple targets"
+  --enable-win32-target=\$t
+                               Specify win32 flavor. (WIN95 or WINNT)"
 ac_help="$ac_help
-  --enable-n32            Enable n32 support (IRIX only)"
+  --enable-n32            Enable n32 ABI support (IRIX only)"
 ac_help="$ac_help
   --enable-64bit          Enable 64-bit support (on certain platforms)"
 ac_help="$ac_help
   --enable-mdupdate       Enable use of certain compilers' mdupdate feature"
 ac_help="$ac_help
   --with-pthreads         Use system pthreads library as thread subsystem"
 ac_help="$ac_help
   --enable-user-pthreads  Build using userland pthreads"
@@ -37,16 +38,18 @@ ac_help="$ac_help
 ac_help="$ac_help
   --with-bthreads         Use system bthreads library as thread subsystem (BeOS only)"
 ac_help="$ac_help
   --with-native-threads   Use native system threads as thread subsystem (Solaris only)"
 ac_help="$ac_help
   --enable-cplus          Use cplus for whatever reason"
 ac_help="$ac_help
   --enable-ipv6           Compile ipv6 support"
+ac_help="$ac_help
+  --enable-boehm          Enable the Boehm Garbage Collector"
 
 # Initialize some variables set by options.
 # The variables have the same names as the options, with
 # dashes changed to underlines.
 build=NONE
 cache_file=./config.cache
 exec_prefix=NONE
 host=NONE
@@ -548,22 +551,16 @@ if (echo "testing\c"; echo 1,2,3) | grep
     ac_n=-n ac_c= ac_t=
   fi
 else
   ac_n= ac_c='\c' ac_t=
 fi
 
 
 
-d=`pwd`
-if test "${srcdir}" = "$d" || test "${srcdir}" = "."  ; then
-   echo "Do not build in the srcdir as it will override Makefiles used by non-autoconf build."
-   exit 1;
-fi
-
 ac_aux_dir=
 for ac_dir in ${srcdir}/build/autoconf $srcdir/${srcdir}/build/autoconf; do
   if test -f $ac_dir/install-sh; then
     ac_aux_dir=$ac_dir
     ac_install_sh="$ac_aux_dir/install-sh -c"
     break
   elif test -f $ac_dir/install.sh; then
     ac_aux_dir=$ac_dir
@@ -601,17 +598,17 @@ esac
 
 
 # Make sure we can run config.sub.
 if ${CONFIG_SHELL-/bin/sh} $ac_config_sub sun4 >/dev/null 2>&1; then :
 else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; }
 fi
 
 echo $ac_n "checking host system type""... $ac_c" 1>&6
-echo "configure:610: checking host system type" >&5
+echo "configure:607: checking host system type" >&5
 
 host_alias=$host
 case "$host_alias" in
 NONE)
   case $nonopt in
   NONE)
     if host_alias=`${CONFIG_SHELL-/bin/sh} $ac_config_guess`; then :
     else { echo "configure: error: can not guess host type; you must specify one" 1>&2; exit 1; }
@@ -622,17 +619,17 @@ esac
 
 host=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $host_alias`
 host_cpu=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
 host_vendor=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
 host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
 echo "$ac_t""$host" 1>&6
 
 echo $ac_n "checking target system type""... $ac_c" 1>&6
-echo "configure:631: checking target system type" >&5
+echo "configure:628: checking target system type" >&5
 
 target_alias=$target
 case "$target_alias" in
 NONE)
   case $nonopt in
   NONE) target_alias=$host_alias ;;
   *) target_alias=$nonopt ;;
   esac ;;
@@ -640,17 +637,17 @@ esac
 
 target=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $target_alias`
 target_cpu=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
 target_vendor=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
 target_os=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
 echo "$ac_t""$target" 1>&6
 
 echo $ac_n "checking build system type""... $ac_c" 1>&6
-echo "configure:649: checking build system type" >&5
+echo "configure:646: checking build system type" >&5
 
 build_alias=$build
 case "$build_alias" in
 NONE)
   case $nonopt in
   NONE) build_alias=$host_alias ;;
   *) build_alias=$nonopt ;;
   esac ;;
@@ -663,35 +660,16 @@ build_os=`echo $build | sed 's/^\([^-]*\
 echo "$ac_t""$build" 1>&6
 
 test "$host_alias" != "$target_alias" &&
   test "$program_prefix$program_suffix$program_transform_name" = \
     NONENONEs,x,x, &&
   program_prefix=${target_alias}-
 
 
-  
-  echo $ac_n "checking cached system tuple""... $ac_c" 1>&6
-echo "configure:674: checking cached system tuple" >&5
-  if { test x"${ac_cv_host_system_type+set}" = x"set" &&
-       test x"$ac_cv_host_system_type" != x"$host"; } ||
-     { test x"${ac_cv_build_system_type+set}" = x"set" &&
-       test x"$ac_cv_build_system_type" != x"$build"; } ||
-     { test x"${ac_cv_target_system_type+set}" = x"set" &&
-       test x"$ac_cv_target_system_type" != x"$target"; }; then
-      echo "$ac_t""different" 1>&6
-      { echo "configure: error: remove config.cache and re-run configure" 1>&2; exit 1; }
-  else
-    echo "$ac_t""ok" 1>&6
-  fi
-  ac_cv_host_system_type="$host"
-  ac_cv_build_system_type="$build"
-  ac_cv_target_system_type="$target"
-
-
 
 cat >> confdefs.h <<\EOF
 #define USE_AUTOCONF 1
 EOF
 
 
 NSPR_VERSION=4
 NSPR_MODNAME=nspr20
@@ -703,24 +681,57 @@ USE_N32=
 USE_64=
 USE_CPLUS=
 USE_IPV6=
 USE_MDUPDATE=
 _OPTIMIZE_FLAGS=-O
 _DEBUG_FLAGS=-g
 MOZ_DEBUG=1
 MOZ_OPTIMIZE=
+OBJDIR=.
+OBJDIR_NAME=.
+NSINSTALL='$(MOD_DEPTH)/config/$(OBJDIR_NAME)/nsinstall'
+NOSUCHFILE=/no-such-file
+
 RESOLVE_LINK_SYMBOLS=
 
 CFLAGS="${CFLAGS=}"
 CXXFLAGS="${CXXFLAGS=}"
 LDFLAGS="${LDFLAGS=}"
 HOST_CFLAGS="${HOST_CFLAGS=}"
 HOST_LDFLAGS="${HOST_LDFLAGS=}"
 
+case "$target" in
+*-irix6*)
+	USE_N32=1 ;;
+*-cygwin*)
+    # Check to see if we are really running in a msvc environemnt
+    _WIN32_MSVC=
+    if test "$CC" = "cl" || test "$CXX" = "cl"; then
+        _WIN32_MSVC=1
+    elif test -z "$CC"; then
+        echo 'main() { return 0; }' > dummy.c
+        cl -o dummy dummy.c
+        if test $? = 0; then
+            _WIN32_MSVC=1
+        fi
+        rm -f dummy dummy.o dummy.obj dummy.exe dummy.c
+    fi
+    ;;
+*-msvc*)
+    _WIN32_MSVC=1
+    ;;
+esac
+
+if test -n "$_WIN32_MSVC"; then
+    SKIP_PATH_CHECKS=1
+    SKIP_COMPILER_CHECKS=1
+    SKIP_LIBRARY_CHECKS=1
+fi
+
 # Check whether --with-mozilla or --without-mozilla was given.
 if test "${with_mozilla+set}" = set; then
   withval="$with_mozilla"
      if test "$withval" = "yes"; then
             cat >> confdefs.h <<\EOF
 #define MOZILLA_CLIENT 1
 EOF
 
@@ -736,17 +747,23 @@ EOF
 
 	    fi
 fi
 
 
 # Check whether --enable-optimize or --disable-optimize was given.
 if test "${enable_optimize+set}" = set; then
   enableval="$enable_optimize"
-  MOZ_OPTIMIZE=1
+   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
+    fi 
 fi
 
 
 # Check whether --enable-debug or --disable-debug was given.
 if test "${enable_debug+set}" = set; then
   enableval="$enable_debug"
   	if test "$enableval" = "no"; then
     	    MOZ_DEBUG=
@@ -756,30 +773,33 @@ fi
 
 # Check whether --enable-shared or --disable-shared was given.
 if test "${enable_shared+set}" = set; then
   enableval="$enable_shared"
   :
 fi
 
 
-# Check whether --enable-target or --disable-target was given.
-if test "${enable_target+set}" = set; then
-  enableval="$enable_target"
-  MOZ_TARGET=`echo $enableval | tr a-z A-Z`
+# Check whether --enable-win32-target or --disable-win32-target was given.
+if test "${enable_win32_target+set}" = set; then
+  enableval="$enable_win32_target"
+  MOZ_WIN32_TARGET=`echo $enableval | tr a-z A-Z`
 else
-  MOZ_TARGET=
+  MOZ_WIN32_TARGET=
 fi
 
 
 # Check whether --enable-n32 or --disable-n32 was given.
 if test "${enable_n32+set}" = set; then
   enableval="$enable_n32"
    if test "$enableval" = "yes"; then
 	USE_N32=1
+      else if test "$enableval" = "no"; then
+	USE_N32=
+      fi
     fi 
 fi
 
 
 # Check whether --enable-64bit or --disable-64bit was given.
 if test "${enable_64bit+set}" = set; then
   enableval="$enable_64bit"
    if test "$enableval" = "yes"; then
@@ -792,20 +812,21 @@ fi
 if test "${enable_mdupdate+set}" = set; then
   enableval="$enable_mdupdate"
    if test "$enableval" = "yes"; then
 	    USE_MDUPDATE=1
       fi 
 fi
 
 
-# Extract the first word of "whoami", so it can be a program name with args.
-set dummy whoami; ac_word=$2
+if test -z "$SKIP_PATH_CHECKS"; then
+    # Extract the first word of "$WHOAMI whoami", so it can be a program name with args.
+set dummy $WHOAMI whoami; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:804: checking for $ac_word" >&5
+echo "configure:825: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_path_WHOAMI'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   case "$WHOAMI" in
   /*)
   ac_cv_path_WHOAMI="$WHOAMI" # Let the user override the test with a path.
   ;;
   ?:/*)			 
@@ -817,62 +838,67 @@ else
   for ac_dir in $ac_dummy; do 
     test -z "$ac_dir" && ac_dir=.
     if test -f $ac_dir/$ac_word; then
       ac_cv_path_WHOAMI="$ac_dir/$ac_word"
       break
     fi
   done
   IFS="$ac_save_ifs"
-  test -z "$ac_cv_path_WHOAMI" && ac_cv_path_WHOAMI=":"
+  test -z "$ac_cv_path_WHOAMI" && ac_cv_path_WHOAMI="echo not_whoami"
   ;;
 esac
 fi
 WHOAMI="$ac_cv_path_WHOAMI"
 if test -n "$WHOAMI"; then
   echo "$ac_t""$WHOAMI" 1>&6
 else
   echo "$ac_t""no" 1>&6
 fi
 
+elif test -z "$WHOAMI"; then
+    WHOAMI=whoami
+fi
+
 if test -n "$MOZ_DEBUG"; then
     cat >> confdefs.h <<\EOF
 #define DEBUG 1
 EOF
 
     cat >> confdefs.h <<EOF
 #define DEBUG_`$WHOAMI` 1
 EOF
 
     DEFINES="$DEFINES -UNDEBUG"
 else
     cat >> confdefs.h <<\EOF
 #define NDEBUG 1
 EOF
 
-    DEFINES="$DEFINES -UDEBUG"    
+    DEFINES="$DEFINES -U_DEBUG -UDEBUG"
 fi
 
+if test -z "$SKIP_COMPILER_CHECKS"; then
 if test "$target" != "$host"; then
     echo "cross compiling from $host to $target"
     cross_compiling=yes
 
     _SAVE_CC="$CC"
     _SAVE_CFLAGS="$CFLAGS"
     _SAVE_LDFLAGS="$LDFLAGS"
 
     echo $ac_n "checking for $host compiler""... $ac_c" 1>&6
-echo "configure:864: checking for $host compiler" >&5
+echo "configure:890: checking for $host compiler" >&5
     if test -z "$HOST_CC"; then
 	    for ac_prog in gcc cc /usr/ucb/cc
 do
 # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:871: checking for $ac_word" >&5
+echo "configure:897: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_HOST_CC'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   if test -n "$HOST_CC"; then
   ac_cv_prog_HOST_CC="$HOST_CC" # Let the user override the test.
 else
   IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
   ac_dummy="$PATH"
@@ -909,26 +935,26 @@ test -n "$HOST_CC" || HOST_CC=""""
 	    HOST_LDFLAGS="$LDFLAGS"
     fi
 
     CC="$HOST_CC"
     CFLAGS="$HOST_CFLAGS"
     LDFLAGS="$HOST_LDFLAGS"
 
     echo $ac_n "checking whether the $host compiler ($HOST_CC $HOST_CFLAGS $HOST_LDFLAGS) works""... $ac_c" 1>&6
-echo "configure:918: checking whether the $host compiler ($HOST_CC $HOST_CFLAGS $HOST_LDFLAGS) works" >&5
+echo "configure:944: checking whether the $host compiler ($HOST_CC $HOST_CFLAGS $HOST_LDFLAGS) works" >&5
     cat > conftest.$ac_ext <<EOF
-#line 920 "configure"
+#line 946 "configure"
 #include "confdefs.h"
 
 int main() {
 return(0);
 ; return 0; }
 EOF
-if { (eval echo configure:927: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:953: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_prog_host_cc_works=1 echo "$ac_t""yes" 1>&6
 else
   echo "configure: failed program was:" >&5
   cat conftest.$ac_ext >&5
   rm -rf conftest*
   { echo "configure: error: installation or configuration problem: $host compiler $HOST_CC cannot create executables." 1>&2; exit 1; } 
 fi
@@ -939,17 +965,17 @@ rm -f conftest*
     LDFLAGS=$_SAVE_LDFLAGS
 
     if test -z "$CC"; then
 	    for ac_prog in "${target_alias}-gcc" "${target}-gcc"
 do
 # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:948: checking for $ac_word" >&5
+echo "configure:974: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   if test -n "$CC"; then
   ac_cv_prog_CC="$CC" # Let the user override the test.
 else
   IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
   ac_dummy="$PATH"
@@ -967,24 +993,24 @@ CC="$ac_cv_prog_CC"
 if test -n "$CC"; then
   echo "$ac_t""$CC" 1>&6
 else
   echo "$ac_t""no" 1>&6
 fi
 
 test -n "$CC" && break
 done
-test -n "$CC" || CC=":"
+test -n "$CC" || CC="echo"
 
     fi
     unset ac_cv_prog_CC
     # Extract the first word of "gcc", so it can be a program name with args.
 set dummy gcc; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:983: checking for $ac_word" >&5
+echo "configure:1009: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   if test -n "$CC"; then
   ac_cv_prog_CC="$CC" # Let the user override the test.
 else
   IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
   ac_dummy="$PATH"
@@ -1004,17 +1030,17 @@ if test -n "$CC"; then
 else
   echo "$ac_t""no" 1>&6
 fi
 
 if test -z "$CC"; then
   # Extract the first word of "cc", so it can be a program name with args.
 set dummy cc; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1013: checking for $ac_word" >&5
+echo "configure:1039: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   if test -n "$CC"; then
   ac_cv_prog_CC="$CC" # Let the user override the test.
 else
   IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
   ac_prog_rejected=no
@@ -1055,17 +1081,17 @@ else
 fi
 
   if test -z "$CC"; then
     case "`uname -s`" in
     *win32* | *WIN32*)
       # Extract the first word of "cl", so it can be a program name with args.
 set dummy cl; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1064: checking for $ac_word" >&5
+echo "configure:1090: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   if test -n "$CC"; then
   ac_cv_prog_CC="$CC" # Let the user override the test.
 else
   IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
   ac_dummy="$PATH"
@@ -1087,33 +1113,33 @@ else
 fi
  ;;
     esac
   fi
   test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; }
 fi
 
 echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
-echo "configure:1096: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
+echo "configure:1122: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
 
 ac_ext=c
 # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
 ac_cpp='$CPP $CPPFLAGS'
 ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
 ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
 cross_compiling=$ac_cv_prog_cc_cross
 
 cat > conftest.$ac_ext << EOF
 
-#line 1107 "configure"
+#line 1133 "configure"
 #include "confdefs.h"
 
 main(){return(0);}
 EOF
-if { (eval echo configure:1112: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1138: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   ac_cv_prog_cc_works=yes
   # If we can't run a trivial program, we are probably using a cross compiler.
   if (./conftest; exit) 2>/dev/null; then
     ac_cv_prog_cc_cross=no
   else
     ac_cv_prog_cc_cross=yes
   fi
 else
@@ -1129,31 +1155,31 @@ ac_compile='${CC-cc} -c $CFLAGS $CPPFLAG
 ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
 cross_compiling=$ac_cv_prog_cc_cross
 
 echo "$ac_t""$ac_cv_prog_cc_works" 1>&6
 if test $ac_cv_prog_cc_works = no; then
   { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; }
 fi
 echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
-echo "configure:1138: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
+echo "configure:1164: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
 echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6
 cross_compiling=$ac_cv_prog_cc_cross
 
 echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6
-echo "configure:1143: checking whether we are using GNU C" >&5
+echo "configure:1169: checking whether we are using GNU C" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.c <<EOF
 #ifdef __GNUC__
   yes;
 #endif
 EOF
-if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:1152: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
+if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:1178: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
   ac_cv_prog_gcc=yes
 else
   ac_cv_prog_gcc=no
 fi
 fi
 
 echo "$ac_t""$ac_cv_prog_gcc" 1>&6
 
@@ -1162,17 +1188,17 @@ if test $ac_cv_prog_gcc = yes; then
 else
   GCC=
 fi
 
 ac_test_CFLAGS="${CFLAGS+set}"
 ac_save_CFLAGS="$CFLAGS"
 CFLAGS=
 echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
-echo "configure:1171: checking whether ${CC-cc} accepts -g" >&5
+echo "configure:1197: checking whether ${CC-cc} accepts -g" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   echo 'void f(){}' > conftest.c
 if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then
   ac_cv_prog_cc_g=yes
 else
   ac_cv_prog_cc_g=no
@@ -1199,17 +1225,17 @@ else
 fi
 
     if test -z "$CXX"; then
 	    for ac_prog in "${target_alias}-g++" "${target}-g++"
 do
 # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1208: checking for $ac_word" >&5
+echo "configure:1234: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_CXX'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   if test -n "$CXX"; then
   ac_cv_prog_CXX="$CXX" # Let the user override the test.
 else
   IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
   ac_dummy="$PATH"
@@ -1227,26 +1253,26 @@ CXX="$ac_cv_prog_CXX"
 if test -n "$CXX"; then
   echo "$ac_t""$CXX" 1>&6
 else
   echo "$ac_t""no" 1>&6
 fi
 
 test -n "$CXX" && break
 done
-test -n "$CXX" || CXX=":"
+test -n "$CXX" || CXX="echo"
 
     fi
     unset ac_cv_prog_CXX
     for ac_prog in $CCC c++ g++ gcc CC cxx cc++ cl
 do
 # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1245: checking for $ac_word" >&5
+echo "configure:1271: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_CXX'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   if test -n "$CXX"; then
   ac_cv_prog_CXX="$CXX" # Let the user override the test.
 else
   IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
   ac_dummy="$PATH"
@@ -1268,33 +1294,33 @@ else
 fi
 
 test -n "$CXX" && break
 done
 test -n "$CXX" || CXX="gcc"
 
 
 echo $ac_n "checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works""... $ac_c" 1>&6
-echo "configure:1277: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works" >&5
+echo "configure:1303: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works" >&5
 
 ac_ext=C
 # CXXFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
 ac_cpp='$CXXCPP $CPPFLAGS'
 ac_compile='${CXX-g++} -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
 ac_link='${CXX-g++} -o conftest${ac_exeext} $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
 cross_compiling=$ac_cv_prog_cxx_cross
 
 cat > conftest.$ac_ext << EOF
 
-#line 1288 "configure"
+#line 1314 "configure"
 #include "confdefs.h"
 
 int main(){return(0);}
 EOF
-if { (eval echo configure:1293: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1319: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   ac_cv_prog_cxx_works=yes
   # If we can't run a trivial program, we are probably using a cross compiler.
   if (./conftest; exit) 2>/dev/null; then
     ac_cv_prog_cxx_cross=no
   else
     ac_cv_prog_cxx_cross=yes
   fi
 else
@@ -1310,31 +1336,31 @@ ac_compile='${CC-cc} -c $CFLAGS $CPPFLAG
 ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
 cross_compiling=$ac_cv_prog_cc_cross
 
 echo "$ac_t""$ac_cv_prog_cxx_works" 1>&6
 if test $ac_cv_prog_cxx_works = no; then
   { echo "configure: error: installation or configuration problem: C++ compiler cannot create executables." 1>&2; exit 1; }
 fi
 echo $ac_n "checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
-echo "configure:1319: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler" >&5
+echo "configure:1345: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler" >&5
 echo "$ac_t""$ac_cv_prog_cxx_cross" 1>&6
 cross_compiling=$ac_cv_prog_cxx_cross
 
 echo $ac_n "checking whether we are using GNU C++""... $ac_c" 1>&6
-echo "configure:1324: checking whether we are using GNU C++" >&5
+echo "configure:1350: checking whether we are using GNU C++" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_gxx'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.C <<EOF
 #ifdef __GNUC__
   yes;
 #endif
 EOF
-if { ac_try='${CXX-g++} -E conftest.C'; { (eval echo configure:1333: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
+if { ac_try='${CXX-g++} -E conftest.C'; { (eval echo configure:1359: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
   ac_cv_prog_gxx=yes
 else
   ac_cv_prog_gxx=no
 fi
 fi
 
 echo "$ac_t""$ac_cv_prog_gxx" 1>&6
 
@@ -1343,17 +1369,17 @@ if test $ac_cv_prog_gxx = yes; then
 else
   GXX=
 fi
 
 ac_test_CXXFLAGS="${CXXFLAGS+set}"
 ac_save_CXXFLAGS="$CXXFLAGS"
 CXXFLAGS=
 echo $ac_n "checking whether ${CXX-g++} accepts -g""... $ac_c" 1>&6
-echo "configure:1352: checking whether ${CXX-g++} accepts -g" >&5
+echo "configure:1378: checking whether ${CXX-g++} accepts -g" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_cxx_g'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   echo 'void f(){}' > conftest.cc
 if test -z "`${CXX-g++} -g -c conftest.cc 2>&1`"; then
   ac_cv_prog_cxx_g=yes
 else
   ac_cv_prog_cxx_g=no
@@ -1380,17 +1406,17 @@ else
 fi
 
     if test -z "$RANLIB"; then
 	    for ac_prog in "${target_alias}-ranlib" "${target}-ranlib"
 do
 # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1389: checking for $ac_word" >&5
+echo "configure:1415: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   if test -n "$RANLIB"; then
   ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
 else
   IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
   ac_dummy="$PATH"
@@ -1408,26 +1434,26 @@ RANLIB="$ac_cv_prog_RANLIB"
 if test -n "$RANLIB"; then
   echo "$ac_t""$RANLIB" 1>&6
 else
   echo "$ac_t""no" 1>&6
 fi
 
 test -n "$RANLIB" && break
 done
-test -n "$RANLIB" || RANLIB=":"
+test -n "$RANLIB" || RANLIB="echo"
 
     fi
     if test -z "$AR"; then
 	    for ac_prog in "${target_alias}-ar" "${target}-ar"
 do
 # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1426: checking for $ac_word" >&5
+echo "configure:1452: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_AR'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   if test -n "$AR"; then
   ac_cv_prog_AR="$AR" # Let the user override the test.
 else
   IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
   ac_dummy="$PATH"
@@ -1445,26 +1471,26 @@ AR="$ac_cv_prog_AR"
 if test -n "$AR"; then
   echo "$ac_t""$AR" 1>&6
 else
   echo "$ac_t""no" 1>&6
 fi
 
 test -n "$AR" && break
 done
-test -n "$AR" || AR=":"
+test -n "$AR" || AR="echo"
 
     fi
     if test -z "$AS"; then
 	    for ac_prog in "${target_alias}-as" "${target}-as"
 do
 # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1463: checking for $ac_word" >&5
+echo "configure:1489: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_AS'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   if test -n "$AS"; then
   ac_cv_prog_AS="$AS" # Let the user override the test.
 else
   IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
   ac_dummy="$PATH"
@@ -1482,26 +1508,26 @@ AS="$ac_cv_prog_AS"
 if test -n "$AS"; then
   echo "$ac_t""$AS" 1>&6
 else
   echo "$ac_t""no" 1>&6
 fi
 
 test -n "$AS" && break
 done
-test -n "$AS" || AS=":"
+test -n "$AS" || AS="echo"
 
     fi
     if test -z "$LD"; then
 	    for ac_prog in "${target_alias}-ld" "${target}-ld"
 do
 # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1500: checking for $ac_word" >&5
+echo "configure:1526: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_LD'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   if test -n "$LD"; then
   ac_cv_prog_LD="$LD" # Let the user override the test.
 else
   IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
   ac_dummy="$PATH"
@@ -1519,26 +1545,63 @@ LD="$ac_cv_prog_LD"
 if test -n "$LD"; then
   echo "$ac_t""$LD" 1>&6
 else
   echo "$ac_t""no" 1>&6
 fi
 
 test -n "$LD" && break
 done
-test -n "$LD" || LD=":"
+test -n "$LD" || LD="echo"
+
+    fi
+    if test -z "$STRIP"; then
+	    for ac_prog in "${target_alias}-strip" "${target}-strip"
+do
+# Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:1563: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_STRIP'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  if test -n "$STRIP"; then
+  ac_cv_prog_STRIP="$STRIP" # Let the user override the test.
+else
+  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
+  ac_dummy="$PATH"
+  for ac_dir in $ac_dummy; do
+    test -z "$ac_dir" && ac_dir=.
+    if test -f $ac_dir/$ac_word; then
+      ac_cv_prog_STRIP="$ac_prog"
+      break
+    fi
+  done
+  IFS="$ac_save_ifs"
+fi
+fi
+STRIP="$ac_cv_prog_STRIP"
+if test -n "$STRIP"; then
+  echo "$ac_t""$STRIP" 1>&6
+else
+  echo "$ac_t""no" 1>&6
+fi
+
+test -n "$STRIP" && break
+done
+test -n "$STRIP" || STRIP="echo"
 
     fi
     if test -z "$DLLTOOL"; then
 	    for ac_prog in "${target_alias}-dlltool" "${target}-dlltool"
 do
 # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1537: checking for $ac_word" >&5
+echo "configure:1600: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_DLLTOOL'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   if test -n "$DLLTOOL"; then
   ac_cv_prog_DLLTOOL="$DLLTOOL" # Let the user override the test.
 else
   IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
   ac_dummy="$PATH"
@@ -1556,26 +1619,26 @@ DLLTOOL="$ac_cv_prog_DLLTOOL"
 if test -n "$DLLTOOL"; then
   echo "$ac_t""$DLLTOOL" 1>&6
 else
   echo "$ac_t""no" 1>&6
 fi
 
 test -n "$DLLTOOL" && break
 done
-test -n "$DLLTOOL" || DLLTOOL=":"
+test -n "$DLLTOOL" || DLLTOOL="echo"
 
     fi
     if test -z "$WINDRES"; then
 	    for ac_prog in "${target_alias}-windres" "${target}-windres"
 do
 # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1574: checking for $ac_word" >&5
+echo "configure:1637: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_WINDRES'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   if test -n "$WINDRES"; then
   ac_cv_prog_WINDRES="$WINDRES" # Let the user override the test.
 else
   IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
   ac_dummy="$PATH"
@@ -1593,24 +1656,171 @@ WINDRES="$ac_cv_prog_WINDRES"
 if test -n "$WINDRES"; then
   echo "$ac_t""$WINDRES" 1>&6
 else
   echo "$ac_t""no" 1>&6
 fi
 
 test -n "$WINDRES" && break
 done
-test -n "$WINDRES" || WINDRES=":"
+test -n "$WINDRES" || WINDRES="echo"
 
     fi
+
 else
-    # Extract the first word of "gcc", so it can be a program name with args.
+    for ac_prog in $CCC c++ g++ gcc CC cxx cc++ cl
+do
+# Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:1675: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_CXX'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  if test -n "$CXX"; then
+  ac_cv_prog_CXX="$CXX" # Let the user override the test.
+else
+  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
+  ac_dummy="$PATH"
+  for ac_dir in $ac_dummy; do
+    test -z "$ac_dir" && ac_dir=.
+    if test -f $ac_dir/$ac_word; then
+      ac_cv_prog_CXX="$ac_prog"
+      break
+    fi
+  done
+  IFS="$ac_save_ifs"
+fi
+fi
+CXX="$ac_cv_prog_CXX"
+if test -n "$CXX"; then
+  echo "$ac_t""$CXX" 1>&6
+else
+  echo "$ac_t""no" 1>&6
+fi
+
+test -n "$CXX" && break
+done
+test -n "$CXX" || CXX="gcc"
+
+
+echo $ac_n "checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works""... $ac_c" 1>&6
+echo "configure:1707: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works" >&5
+
+ac_ext=C
+# CXXFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='${CXX-g++} -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
+ac_link='${CXX-g++} -o conftest${ac_exeext} $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+cross_compiling=$ac_cv_prog_cxx_cross
+
+cat > conftest.$ac_ext << EOF
+
+#line 1718 "configure"
+#include "confdefs.h"
+
+int main(){return(0);}
+EOF
+if { (eval echo configure:1723: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+  ac_cv_prog_cxx_works=yes
+  # If we can't run a trivial program, we are probably using a cross compiler.
+  if (./conftest; exit) 2>/dev/null; then
+    ac_cv_prog_cxx_cross=no
+  else
+    ac_cv_prog_cxx_cross=yes
+  fi
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  ac_cv_prog_cxx_works=no
+fi
+rm -fr conftest*
+ac_ext=c
+# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
+ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+cross_compiling=$ac_cv_prog_cc_cross
+
+echo "$ac_t""$ac_cv_prog_cxx_works" 1>&6
+if test $ac_cv_prog_cxx_works = no; then
+  { echo "configure: error: installation or configuration problem: C++ compiler cannot create executables." 1>&2; exit 1; }
+fi
+echo $ac_n "checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
+echo "configure:1749: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler" >&5
+echo "$ac_t""$ac_cv_prog_cxx_cross" 1>&6
+cross_compiling=$ac_cv_prog_cxx_cross
+
+echo $ac_n "checking whether we are using GNU C++""... $ac_c" 1>&6
+echo "configure:1754: checking whether we are using GNU C++" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_gxx'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  cat > conftest.C <<EOF
+#ifdef __GNUC__
+  yes;
+#endif
+EOF
+if { ac_try='${CXX-g++} -E conftest.C'; { (eval echo configure:1763: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
+  ac_cv_prog_gxx=yes
+else
+  ac_cv_prog_gxx=no
+fi
+fi
+
+echo "$ac_t""$ac_cv_prog_gxx" 1>&6
+
+if test $ac_cv_prog_gxx = yes; then
+  GXX=yes
+else
+  GXX=
+fi
+
+ac_test_CXXFLAGS="${CXXFLAGS+set}"
+ac_save_CXXFLAGS="$CXXFLAGS"
+CXXFLAGS=
+echo $ac_n "checking whether ${CXX-g++} accepts -g""... $ac_c" 1>&6
+echo "configure:1782: checking whether ${CXX-g++} accepts -g" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_cxx_g'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  echo 'void f(){}' > conftest.cc
+if test -z "`${CXX-g++} -g -c conftest.cc 2>&1`"; then
+  ac_cv_prog_cxx_g=yes
+else
+  ac_cv_prog_cxx_g=no
+fi
+rm -f conftest*
+
+fi
+
+echo "$ac_t""$ac_cv_prog_cxx_g" 1>&6
+if test "$ac_test_CXXFLAGS" = set; then
+  CXXFLAGS="$ac_save_CXXFLAGS"
+elif test $ac_cv_prog_cxx_g = yes; then
+  if test "$GXX" = yes; then
+    CXXFLAGS="-g -O2"
+  else
+    CXXFLAGS="-g"
+  fi
+else
+  if test "$GXX" = yes; then
+    CXXFLAGS="-O2"
+  else
+    CXXFLAGS=
+  fi
+fi
+
+    if test "$CXX" = "cl" -a -z "$CC"; then
+        CC=$CXX
+    else        
+        # Extract the first word of "gcc", so it can be a program name with args.
 set dummy gcc; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1609: checking for $ac_word" >&5
+echo "configure:1819: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   if test -n "$CC"; then
   ac_cv_prog_CC="$CC" # Let the user override the test.
 else
   IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
   ac_dummy="$PATH"
@@ -1630,17 +1840,17 @@ if test -n "$CC"; then
 else
   echo "$ac_t""no" 1>&6
 fi
 
 if test -z "$CC"; then
   # Extract the first word of "cc", so it can be a program name with args.
 set dummy cc; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1639: checking for $ac_word" >&5
+echo "configure:1849: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   if test -n "$CC"; then
   ac_cv_prog_CC="$CC" # Let the user override the test.
 else
   IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
   ac_prog_rejected=no
@@ -1681,17 +1891,17 @@ else
 fi
 
   if test -z "$CC"; then
     case "`uname -s`" in
     *win32* | *WIN32*)
       # Extract the first word of "cl", so it can be a program name with args.
 set dummy cl; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1690: checking for $ac_word" >&5
+echo "configure:1900: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   if test -n "$CC"; then
   ac_cv_prog_CC="$CC" # Let the user override the test.
 else
   IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
   ac_dummy="$PATH"
@@ -1713,33 +1923,33 @@ else
 fi
  ;;
     esac
   fi
   test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; }
 fi
 
 echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
-echo "configure:1722: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
+echo "configure:1932: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
 
 ac_ext=c
 # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
 ac_cpp='$CPP $CPPFLAGS'
 ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
 ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
 cross_compiling=$ac_cv_prog_cc_cross
 
 cat > conftest.$ac_ext << EOF
 
-#line 1733 "configure"
+#line 1943 "configure"
 #include "confdefs.h"
 
 main(){return(0);}
 EOF
-if { (eval echo configure:1738: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1948: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   ac_cv_prog_cc_works=yes
   # If we can't run a trivial program, we are probably using a cross compiler.
   if (./conftest; exit) 2>/dev/null; then
     ac_cv_prog_cc_cross=no
   else
     ac_cv_prog_cc_cross=yes
   fi
 else
@@ -1755,31 +1965,31 @@ ac_compile='${CC-cc} -c $CFLAGS $CPPFLAG
 ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
 cross_compiling=$ac_cv_prog_cc_cross
 
 echo "$ac_t""$ac_cv_prog_cc_works" 1>&6
 if test $ac_cv_prog_cc_works = no; then
   { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; }
 fi
 echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
-echo "configure:1764: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
+echo "configure:1974: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
 echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6
 cross_compiling=$ac_cv_prog_cc_cross
 
 echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6
-echo "configure:1769: checking whether we are using GNU C" >&5
+echo "configure:1979: checking whether we are using GNU C" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.c <<EOF
 #ifdef __GNUC__
   yes;
 #endif
 EOF
-if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:1778: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
+if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:1988: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
   ac_cv_prog_gcc=yes
 else
   ac_cv_prog_gcc=no
 fi
 fi
 
 echo "$ac_t""$ac_cv_prog_gcc" 1>&6
 
@@ -1788,17 +1998,17 @@ if test $ac_cv_prog_gcc = yes; then
 else
   GCC=
 fi
 
 ac_test_CFLAGS="${CFLAGS+set}"
 ac_save_CFLAGS="$CFLAGS"
 CFLAGS=
 echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
-echo "configure:1797: checking whether ${CC-cc} accepts -g" >&5
+echo "configure:2007: checking whether ${CC-cc} accepts -g" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   echo 'void f(){}' > conftest.c
 if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then
   ac_cv_prog_cc_g=yes
 else
   ac_cv_prog_cc_g=no
@@ -1819,163 +2029,21 @@ elif test $ac_cv_prog_cc_g = yes; then
 else
   if test "$GCC" = yes; then
     CFLAGS="-O2"
   else
     CFLAGS=
   fi
 fi
 
-    for ac_prog in $CCC c++ g++ gcc CC cxx cc++ cl
-do
-# Extract the first word of "$ac_prog", so it can be a program name with args.
-set dummy $ac_prog; ac_word=$2
-echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1833: checking for $ac_word" >&5
-if eval "test \"`echo '$''{'ac_cv_prog_CXX'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
-else
-  if test -n "$CXX"; then
-  ac_cv_prog_CXX="$CXX" # Let the user override the test.
-else
-  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
-  ac_dummy="$PATH"
-  for ac_dir in $ac_dummy; do
-    test -z "$ac_dir" && ac_dir=.
-    if test -f $ac_dir/$ac_word; then
-      ac_cv_prog_CXX="$ac_prog"
-      break
     fi
-  done
-  IFS="$ac_save_ifs"
-fi
-fi
-CXX="$ac_cv_prog_CXX"
-if test -n "$CXX"; then
-  echo "$ac_t""$CXX" 1>&6
-else
-  echo "$ac_t""no" 1>&6
-fi
-
-test -n "$CXX" && break
-done
-test -n "$CXX" || CXX="gcc"
-
-
-echo $ac_n "checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works""... $ac_c" 1>&6
-echo "configure:1865: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works" >&5
-
-ac_ext=C
-# CXXFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
-ac_cpp='$CXXCPP $CPPFLAGS'
-ac_compile='${CXX-g++} -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
-ac_link='${CXX-g++} -o conftest${ac_exeext} $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
-cross_compiling=$ac_cv_prog_cxx_cross
-
-cat > conftest.$ac_ext << EOF
-
-#line 1876 "configure"
-#include "confdefs.h"
-
-int main(){return(0);}
-EOF
-if { (eval echo configure:1881: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
-  ac_cv_prog_cxx_works=yes
-  # If we can't run a trivial program, we are probably using a cross compiler.
-  if (./conftest; exit) 2>/dev/null; then
-    ac_cv_prog_cxx_cross=no
-  else
-    ac_cv_prog_cxx_cross=yes
-  fi
-else
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  ac_cv_prog_cxx_works=no
-fi
-rm -fr conftest*
-ac_ext=c
-# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
-ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
-cross_compiling=$ac_cv_prog_cc_cross
-
-echo "$ac_t""$ac_cv_prog_cxx_works" 1>&6
-if test $ac_cv_prog_cxx_works = no; then
-  { echo "configure: error: installation or configuration problem: C++ compiler cannot create executables." 1>&2; exit 1; }
-fi
-echo $ac_n "checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
-echo "configure:1907: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler" >&5
-echo "$ac_t""$ac_cv_prog_cxx_cross" 1>&6
-cross_compiling=$ac_cv_prog_cxx_cross
-
-echo $ac_n "checking whether we are using GNU C++""... $ac_c" 1>&6
-echo "configure:1912: checking whether we are using GNU C++" >&5
-if eval "test \"`echo '$''{'ac_cv_prog_gxx'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
-else
-  cat > conftest.C <<EOF
-#ifdef __GNUC__
-  yes;
-#endif
-EOF
-if { ac_try='${CXX-g++} -E conftest.C'; { (eval echo configure:1921: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
-  ac_cv_prog_gxx=yes
-else
-  ac_cv_prog_gxx=no
-fi
-fi
-
-echo "$ac_t""$ac_cv_prog_gxx" 1>&6
-
-if test $ac_cv_prog_gxx = yes; then
-  GXX=yes
-else
-  GXX=
-fi
-
-ac_test_CXXFLAGS="${CXXFLAGS+set}"
-ac_save_CXXFLAGS="$CXXFLAGS"
-CXXFLAGS=
-echo $ac_n "checking whether ${CXX-g++} accepts -g""... $ac_c" 1>&6
-echo "configure:1940: checking whether ${CXX-g++} accepts -g" >&5
-if eval "test \"`echo '$''{'ac_cv_prog_cxx_g'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
-else
-  echo 'void f(){}' > conftest.cc
-if test -z "`${CXX-g++} -g -c conftest.cc 2>&1`"; then
-  ac_cv_prog_cxx_g=yes
-else
-  ac_cv_prog_cxx_g=no
-fi
-rm -f conftest*
-
-fi
-
-echo "$ac_t""$ac_cv_prog_cxx_g" 1>&6
-if test "$ac_test_CXXFLAGS" = set; then
-  CXXFLAGS="$ac_save_CXXFLAGS"
-elif test $ac_cv_prog_cxx_g = yes; then
-  if test "$GXX" = yes; then
-    CXXFLAGS="-g -O2"
-  else
-    CXXFLAGS="-g"
-  fi
-else
-  if test "$GXX" = yes; then
-    CXXFLAGS="-O2"
-  else
-    CXXFLAGS=
-  fi
-fi
-
     # Extract the first word of "ranlib", so it can be a program name with args.
 set dummy ranlib; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1974: checking for $ac_word" >&5
+echo "configure:2042: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   if test -n "$RANLIB"; then
   ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
 else
   IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
   ac_dummy="$PATH"
@@ -1997,17 +2065,17 @@ else
   echo "$ac_t""no" 1>&6
 fi
 
     for ac_prog in as
 do
 # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:2006: checking for $ac_word" >&5
+echo "configure:2074: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_path_AS'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   case "$AS" in
   /*)
   ac_cv_path_AS="$AS" # Let the user override the test with a path.
   ;;
   ?:/*)			 
@@ -2038,17 +2106,17 @@ test -n "$AS" && break
 done
 test -n "$AS" || AS="$CC"
 
     for ac_prog in ar
 do
 # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:2047: checking for $ac_word" >&5
+echo "configure:2115: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_path_AR'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   case "$AR" in
   /*)
   ac_cv_path_AR="$AR" # Let the user override the test with a path.
   ;;
   ?:/*)			 
@@ -2072,24 +2140,24 @@ AR="$ac_cv_path_AR"
 if test -n "$AR"; then
   echo "$ac_t""$AR" 1>&6
 else
   echo "$ac_t""no" 1>&6
 fi
 
 test -n "$AR" && break
 done
-test -n "$AR" || AR=":"
-
-    for ac_prog in ld
+test -n "$AR" || AR="echo not_ar"
+
+    for ac_prog in ld link
 do
 # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:2088: checking for $ac_word" >&5
+echo "configure:2156: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_path_LD'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   case "$LD" in
   /*)
   ac_cv_path_LD="$LD" # Let the user override the test with a path.
   ;;
   ?:/*)			 
@@ -2113,24 +2181,65 @@ LD="$ac_cv_path_LD"
 if test -n "$LD"; then
   echo "$ac_t""$LD" 1>&6
 else
   echo "$ac_t""no" 1>&6
 fi
 
 test -n "$LD" && break
 done
-test -n "$LD" || LD=":"
+test -n "$LD" || LD="echo not_ld"
+
+    for ac_prog in strip
+do
+# Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:2197: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_path_STRIP'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  case "$STRIP" in
+  /*)
+  ac_cv_path_STRIP="$STRIP" # Let the user override the test with a path.
+  ;;
+  ?:/*)			 
+  ac_cv_path_STRIP="$STRIP" # Let the user override the test with a dos path.
+  ;;
+  *)
+  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
+  ac_dummy="$PATH"
+  for ac_dir in $ac_dummy; do 
+    test -z "$ac_dir" && ac_dir=.
+    if test -f $ac_dir/$ac_word; then
+      ac_cv_path_STRIP="$ac_dir/$ac_word"
+      break
+    fi
+  done
+  IFS="$ac_save_ifs"
+  ;;
+esac
+fi
+STRIP="$ac_cv_path_STRIP"
+if test -n "$STRIP"; then
+  echo "$ac_t""$STRIP" 1>&6
+else
+  echo "$ac_t""no" 1>&6
+fi
+
+test -n "$STRIP" && break
+done
+test -n "$STRIP" || STRIP="echo not_strip"
 
     for ac_prog in dlltool
 do
 # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:2129: checking for $ac_word" >&5
+echo "configure:2238: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_path_DLLTOOL'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   case "$DLLTOOL" in
   /*)
   ac_cv_path_DLLTOOL="$DLLTOOL" # Let the user override the test with a path.
   ;;
   ?:/*)			 
@@ -2154,24 +2263,24 @@ DLLTOOL="$ac_cv_path_DLLTOOL"
 if test -n "$DLLTOOL"; then
   echo "$ac_t""$DLLTOOL" 1>&6
 else
   echo "$ac_t""no" 1>&6
 fi
 
 test -n "$DLLTOOL" && break
 done
-test -n "$DLLTOOL" || DLLTOOL=":"
+test -n "$DLLTOOL" || DLLTOOL="echo not_dlltool"
 
     for ac_prog in windres
 do
 # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:2170: checking for $ac_word" >&5
+echo "configure:2279: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_path_WINDRES'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   case "$WINDRES" in
   /*)
   ac_cv_path_WINDRES="$WINDRES" # Let the user override the test with a path.
   ;;
   ?:/*)			 
@@ -2195,17 +2304,17 @@ WINDRES="$ac_cv_path_WINDRES"
 if test -n "$WINDRES"; then
   echo "$ac_t""$WINDRES" 1>&6
 else
   echo "$ac_t""no" 1>&6
 fi
 
 test -n "$WINDRES" && break
 done
-test -n "$WINDRES" || WINDRES=":"
+test -n "$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
 fi
@@ -2213,107 +2322,31 @@ fi
 if test "$GCC" = "yes"; then
     GNU_CC=1
 fi
 if test "`echo | $AS -V 2>&1 | grep -c GNU`" != "0"; then
     GNU_AS=1
 fi
 rm -f a.out
 
-# Find a good install program.  We prefer a C program (faster),
-# so one script is as good as another.  But avoid the broken or
-# incompatible versions:
-# SysV /etc/install, /usr/sbin/install
-# SunOS /usr/etc/install
-# IRIX /sbin/install
-# AIX /bin/install
-# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
-# AFS /usr/afsws/bin/install, which mishandles nonexistent args
-# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
-# ./install, which can be erroneously created by make from ./install.sh.
-echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
-echo "configure:2234: checking for a BSD compatible install" >&5
-if test -z "$INSTALL"; then
-if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
+if test "$cross_compiling"  = "yes"; then
+    CROSS_COMPILE=1
 else
-    IFS="${IFS= 	}"; ac_save_IFS="$IFS"; IFS=":"
-  for ac_dir in $PATH; do
-    # Account for people who put trailing slashes in PATH elements.
-    case "$ac_dir/" in
-    /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;;
-    *)
-      # OSF1 and SCO ODT 3.0 have their own names for install.
-      # Don't use installbsd from OSF since it installs stuff as root
-      # by default.
-      for ac_prog in ginstall scoinst install; do
-        if test -f $ac_dir/$ac_prog; then
-	  if test $ac_prog = install &&
-            grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then
-	    # AIX install.  It has an incompatible calling convention.
-	    :
-	  else
-	    ac_cv_path_install="$ac_dir/$ac_prog -c"
-	    break 2
-	  fi
-	fi
-      done
-      ;;
-    esac
-  done
-  IFS="$ac_save_IFS"
-
+    CROSS_COMPILE=
 fi
-  if test "${ac_cv_path_install+set}" = set; then
-    INSTALL="$ac_cv_path_install"
-  else
-    # As a last resort, use the slow shell script.  We don't cache a
-    # path for INSTALL within a source directory, because that will
-    # break other packages using the cache if that directory is
-    # removed, or if the path is relative.
-    INSTALL="$ac_install_sh"
-  fi
-fi
-echo "$ac_t""$INSTALL" 1>&6
-
-# Use test -z because SunOS4 sh mishandles braces in ${var-val}.
-# It thinks the first close brace ends the variable substitution.
-test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
-
-test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}'
-
-test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
-
-echo $ac_n "checking whether ln -s works""... $ac_c" 1>&6
-echo "configure:2287: checking whether ln -s works" >&5
-if eval "test \"`echo '$''{'ac_cv_prog_LN_S'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
-else
-  rm -f conftestdata
-if ln -s X conftestdata 2>/dev/null
-then
-  rm -f conftestdata
-  ac_cv_prog_LN_S="ln -s"
-else
-  ac_cv_prog_LN_S=ln
-fi
-fi
-LN_S="$ac_cv_prog_LN_S"
-if test "$ac_cv_prog_LN_S" = "ln -s"; then
-  echo "$ac_t""yes" 1>&6
-else
-  echo "$ac_t""no" 1>&6
-fi
-
-for ac_prog in perl5 perl
+
+fi # SKIP_COMPILER_CHECKS
+
+if test -z "$SKIP_PATH_CHECKS"; then
+    for ac_prog in perl5 perl
 do
 # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:2312: checking for $ac_word" >&5
+echo "configure:2345: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_path_PERL'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   case "$PERL" in
   /*)
   ac_cv_path_PERL="$PERL" # Let the user override the test with a path.
   ;;
   ?:/*)			 
@@ -2337,35 +2370,165 @@ PERL="$ac_cv_path_PERL"
 if test -n "$PERL"; then
   echo "$ac_t""$PERL" 1>&6
 else
   echo "$ac_t""no" 1>&6
 fi
 
 test -n "$PERL" && break
 done
-test -n "$PERL" || PERL=":"
-
+test -n "$PERL" || PERL="echo not_perl"
+
+elif test -z "$PERL"; then
+    PERL=perl
+fi
 
 OBJ_SUFFIX=o
 LIB_SUFFIX=a
 DLL_SUFFIX=so
 MKSHLIB='$(LD) $(DSO_LDOPTS) -o $@'
 PR_MD_ASFILES=
 PR_MD_CSRCS=
 PR_MD_ARCH_DIR=unix
 AR_FLAGS='cr $@'
-
-OS_TARGET=`uname -s`
+AS='$(CC)'
+
 OS_ARCH=`uname -s | sed -e 's|/|_|g'`
 OS_RELEASE=`uname -r`
 OS_TEST=`uname -m`
 
+if test "$OS_ARCH" = "IRIX64"; then
+    OS_ARCH=IRIX
+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.
+#
+if test "$OS_ARCH" = "WIN95"; then
+    OS_ARCH=WINNT
+    OS_TARGET=WIN95
+elif test "$OS_ARCH" = 'Windows_95'; then
+    OS_ARCH=Windows_NT
+    OS_TARGET=WIN95
+elif test "$OS_ARCH" = "CYGWIN_95-4.0"; then
+    OS_ARCH='CYGWIN_NT-4.0'
+    OS_TARGET=WIN95
+elif test "$OS_ARCH" = "OS2"; then
+    OS_ARCH=OS2
+    OS_TARGET=OS2
+fi
+
+#
+# On WIN32, we also define the variable CPU_ARCH.
+#
+
+if test "$OS_ARCH" = "WINNT"; then
+    CPU_ARCH=`uname -p`
+    if test "$CPU_ARCH" = "I386"; then
+        CPU_ARCH=x86
+    fi
+elif test "$OS_ARCH" = "Windows_NT"; then
+#
+# 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
+elif echo "$OS_ARCH" | grep -c CYGWIN_NT >/dev/null; then
+#
+# If uname -s returns "CYGWIN_NT-4.0", we assume that we are using
+# the uname.exe in the Cygwin tools.
+#
+    OS_RELEASE=`echo $OS_ARCH | sed 's|^CYGWIN_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
+elif test "$OS_ARCH" = "CYGWIN32_NT"; then
+#
+# 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.
+#
+    OS_ARCH=WINNT
+    CPU_ARCH=`uname -m`
+    #
+    # GNU-Win32's uname -m returns "i686" on a Pentium Pro machine.
+    #
+    if echo "$CPU_ARCH" | grep -c 86 >/dev/null; then
+        CPU_ARCH=x86
+    fi
+fi
+
+if test -n "$MOZILLA_CLIENT" && test "$OS_ARCH" = "WINNT"; then
+    OS_TARGET=WIN95
+    MOZ_WIN32_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
+if test -z "$MOZ_WIN32_TARGET"; then
+    MOZ_WIN32_TARGET=$OS_TARGET
+fi
+OS_CONFIG="${OS_TARGET}${OS_RELEASE}"
+
+
 case "$host" in
-*-mingw*)
+*-mingw*|*-cygwin*|*-msvc*)
     ;;
 *-beos*)
     HOST_CFLAGS="$HOST_CFLAGS -DXP_BEOS -DBeOS -DBEOS -D_POSIX_SOURCE"
     ;;
 *)
     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
     ;;
 esac
@@ -2381,16 +2544,17 @@ EOF
 #define AIX 1
 EOF
 
     cat >> confdefs.h <<\EOF
 #define SYSV 1
 EOF
 
     DSO_LDOPTS='-brtl -bM:SRE -bnoentry -bexpall'
+    OS_LIBS="-lc_r $OS_LIBS"
     case "${target_os}" in
     aix3.2*)
         USE_NSPR_THREADS=1
         cat >> confdefs.h <<\EOF
 #define _PR_LOCAL_THREADS_ONLY 1
 EOF
 
         cat >> confdefs.h <<\EOF
@@ -2422,16 +2586,17 @@ EOF
 EOF
 
         cat >> confdefs.h <<\EOF
 #define AIX4_1 1
 EOF
 
         MKSHLIB=
         DSO_LDOPTS=
+        USE_PTHREADS=1
         AIX_LINK_OPTS='-bnso -berok'
         ;;
     aix4.3*)
         cat >> confdefs.h <<\EOF
 #define AIX_HAVE_ATOMIC_OP_H 1
 EOF
 
         cat >> confdefs.h <<\EOF
@@ -2446,16 +2611,17 @@ EOF
 #define AIX4_3 1
 EOF
 
         cat >> confdefs.h <<\EOF
 #define HAVE_SOCKLEN_T 1
 EOF
 
         USE_IPV6=1
+        USE_PTHREADS=1
         AIX_LINK_OPTS='-brtl -bnso -berok'
         ;;
     *)
         cat >> confdefs.h <<\EOF
 #define AIX_HAVE_ATOMIC_OP_H 1
 EOF
 
         cat >> confdefs.h <<\EOF
@@ -2465,31 +2631,32 @@ EOF
         cat >> confdefs.h <<\EOF
 #define _PR_HAVE_OFF64_T 1
 EOF
 
         AIX_LINK_OPTS='-brtl -bnso -berok'
         ;;
     esac
     CFLAGS="$CFLAGS -qro -qroconst"
-    if test `grep -c xlC_r $CC`; then
+    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
         MDCPUCFG_H=_aix64.cfg
     else
         if test -n "$USE_IPV6"; then
             MDCPUCFG_H=_aix32in6.cfg
         else
             MDCPUCFG_H=_aix32.cfg
         fi
     fi
     PR_MD_CSRCS=aix.c
+    RESOLVE_LINK_SYMBOLS=1
     ;;
         
 *-beos*)
     cat >> confdefs.h <<\EOF
 #define XP_BEOS 1
 EOF
 
     cat >> confdefs.h <<\EOF
@@ -2500,21 +2667,170 @@ EOF
 #define BEOS 1
 EOF
 
     cat >> confdefs.h <<\EOF
 #define _POSIX_SOURCE 1
 EOF
 
     DSO_LDOPTS=-nostart
-    MKSHLIB='$(CCC) $(DSO_LDOPTS) -o $@'
     MDCPUCFG_H=_beos.cfg
     USE_BTHREADS=1
     PR_MD_ARCH_DIR=beos
     RESOLVE_LINK_SYMBOLS=1
+    case "${target_cpu}" in
+    i?86)
+        _OPTIMIZE_FLAGS=-O2
+        _DEBUG_FLAGS='-gdwarf-2 -O0'
+        MKSHLIB='$(CCC) $(DSO_LDOPTS) -o $@'
+        ;;
+    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*)
+    cat >> confdefs.h <<\EOF
+#define XP_UNIX 1
+EOF
+
+    cat >> confdefs.h <<\EOF
+#define BSDI 1
+EOF
+
+    cat >> confdefs.h <<\EOF
+#define NEED_BSDREGEX 1
+EOF
+
+
+    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
+
+    MDCPUCFG_H=_bsdi.cfg
+    PR_MD_CSRCS=bsdi.c
+
+    DSO_LDOPTS=-r
+
+    case "$target_os" in
+    bsdi1.1*)
+        cat >> confdefs.h <<\EOF
+#define _PR_BSDI_JMPBUF_IS_ARRAY 1
+EOF
+
+        cat >> confdefs.h <<\EOF
+#define _PR_STAT_HAS_ONLY_ST_ATIME 1
+EOF
+
+        cat >> confdefs.h <<\EOF
+#define _PR_NEED_H_ERRNO 1
+EOF
+
+        MKSHLIB=
+        DSO_CFLAGS=
+        DSO_LDOPTS=
+        ;;
+
+    bsdi2.1*)
+        cat >> confdefs.h <<\EOF
+#define _PR_TIMESPEC_HAS_TS_SEC 1
+EOF
+
+        cat >> confdefs.h <<\EOF
+#define _PR_BSDI_JMPBUF_IS_ARRAY 1
+EOF
+
+        cat >> confdefs.h <<\EOF
+#define HAVE_DLL 1
+EOF
+
+        cat >> confdefs.h <<\EOF
+#define USE_DLFCN 1
+EOF
+
+        cat >> confdefs.h <<\EOF
+#define _PR_STAT_HAS_ST_ATIMESPEC 1
+EOF
+
+        PR_MD_ASFILES=os_BSD_OS_386_2.s
+        ;;
+
+    bsdi4.*)
+        cat >> confdefs.h <<\EOF
+#define _PR_SELECT_CONST_TIMEVAL 1
+EOF
+
+        cat >> confdefs.h <<\EOF
+#define _PR_BSDI_JMPBUF_IS_STRUCT 1
+EOF
+
+        cat >> confdefs.h <<\EOF
+#define HAVE_DLL 1
+EOF
+
+        cat >> confdefs.h <<\EOF
+#define USE_DLFCN 1
+EOF
+
+        cat >> confdefs.h <<\EOF
+#define _PR_STAT_HAS_ST_ATIMESPEC 1
+EOF
+
+        MKSHLIB='$(CC) -o $@ $(DSO_LDOPTS)'
+        DSO_CFLAGS=-fPIC
+        DSO_LDOPTS='-shared -Wl,-soname,$(@:$(OBJDIR)/%.so=%.so)'
+        STRIP="$STRIP -d"
+        case "$target_os" in
+        bsdi4.2*)
+            cat >> confdefs.h <<\EOF
+#define _PR_HAVE_GETPROTO_R 1
+EOF
+
+            cat >> confdefs.h <<\EOF
+#define _PR_HAVE_GETPROTO_R_POINTER 1
+EOF
+
+            ;;
+        esac
+        ;;
+    *)
+        cat >> confdefs.h <<\EOF
+#define _PR_SELECT_CONST_TIMEVAL 1
+EOF
+
+        cat >> confdefs.h <<\EOF
+#define _PR_BSDI_JMPBUF_IS_STRUCT 1
+EOF
+
+        cat >> confdefs.h <<\EOF
+#define HAVE_DLL 1
+EOF
+
+        cat >> confdefs.h <<\EOF
+#define USE_DLFCN 1
+EOF
+
+        cat >> confdefs.h <<\EOF
+#define _PR_STAT_HAS_ST_ATIMESPEC 1
+EOF
+
+        ;;
+    esac
+
     ;;
 
 *-dgux*)
     cat >> confdefs.h <<\EOF
 #define XP_UNIX 1
 EOF
 
     cat >> confdefs.h <<\EOF
@@ -2536,32 +2852,24 @@ EOF
     cat >> confdefs.h <<\EOF
 #define _DGUX_SOURCE 1
 EOF
 
     cat >> confdefs.h <<\EOF
 #define _POSIX4A_DRAFT6_SOURCE 1
 EOF
 
-    MKSHLIB='$(LD) $(DSO_LDOPTS)'
     DSO_LDOPTS=-G
-    NOSUCHFILE=/no-such-file
     _OPTIMIZE_FLAGS=-O2
     _DEBUG_FLAGS=
     MDCPUCFG_H=_dgux.cfg
     PR_MD_CSRCS=dgux.c
     ;;
 
 *-freebsd*)
-    if test "${target_cpu}" != "alpha"; then
-        cat >> confdefs.h <<\EOF
-#define i386 1
-EOF
-
-    fi
     cat >> confdefs.h <<\EOF
 #define FREEBSD 1
 EOF
 
     cat >> confdefs.h <<\EOF
 #define HAVE_BSD_FLOCK 1
 EOF
 
@@ -2575,24 +2883,31 @@ EOF
     DSO_CFLAGS=-fPIC
     DSO_LDOPTS=-Bshareable
     MDCPUCFG_H=_freebsd.cfg
     PR_MD_CSRCS=freebsd.c
     ;;
 
 *-hpux*)
     cat >> confdefs.h <<\EOF
+#define XP_UNIX 1
+EOF
+
+    cat >> confdefs.h <<\EOF
 #define HPUX 1
 EOF
 
     cat >> confdefs.h <<\EOF
 #define _HPUX_SOURCE 1
 EOF
 
-    DEFINES="$DEFINES -D${target_cpu}"
+    cat >> confdefs.h <<\EOF
+#define hppa 1
+EOF
+
     DLL_SUFFIX=sl
     DSO_LDOPTS='-b +h $(notdir $@)'
     PR_MD_CSRCS=hpux.c
     if test -n "$USE_64"; then
         MDCPUCFG_H=_hpux64.cfg
     else
         MDCPUCFG_H=_hpux32.cfg
     fi
@@ -2600,89 +2915,116 @@ EOF
         CC="$CC -Ae"
         CXX="$CXX -ext"
         CFLAGS="$CFLAGS +ESlit"
         CXXFLAGS="$CXXFLAGS +ESlit"
         DSO_CFLAGS=+Z
     else
         DSO_CFLAGS=-fPIC
     fi
+
     if test -n "$MOZILLA_CLIENT"; then
-        USE_NSPR_THREADS=1
+        DEFAULT_IMPL_STRATEGY=_EMU
     fi
-    case "${target_os}" in
-    hpuxA.09*)
-        cat >> confdefs.h <<\EOF
-#define HPUX9 1
-EOF
-
+
+    if echo "$OS_RELEASE" | grep ^A.09 >/dev/null; then
         cat >> confdefs.h <<\EOF
 #define _PR_NEED_H_ERRNO 1
 EOF
 
         cat >> confdefs.h <<\EOF
+#define HPUX9 1
+EOF
+
+        DEFAULT_IMPL_STRATEGY=_EMU
+    	USE_NSPR_THREADS=1
+    fi
+
+    if echo "$OS_RELEASE" | egrep '^(A.09|B.10)' >/dev/null; then
+        cat >> confdefs.h <<\EOF
 #define _PR_NO_LARGE_FILES 1
 EOF
 
-        ;;
-    hpuxB.10.01*)
+    fi
+
+    if echo "$OS_RELEASE" | egrep '^(B.10.10|B.10.20)' >/dev/null; then
+        cat >> confdefs.h <<\EOF
+#define _PR_NEED_H_ERRNO 1
+EOF
+
+    fi
+
+    if echo "$OS_RELEASE" | egrep '^(B.10.10|B.10.20)' >/dev/null; then
+        cat >> confdefs.h <<\EOF
+#define HAVE_INT_LOCALTIME_R 1
+EOF
+
+    fi
+
+    if echo "$OS_RELEASE" | egrep '^(B.10.30|B.11.00)' >/dev/null; then
+        cat >> confdefs.h <<\EOF
+#define HAVE_POINTER_LOCALTIME_R 1
+EOF
+
+    fi
+
+    if test "$OS_RELEASE" = "B.10.01"; then
         cat >> confdefs.h <<\EOF
 #define HPUX10 1
 EOF
 
-        ;;
-    hpuxB.10.10*)
+        DEFAULT_IMPL_STRATEGY=_EMU
+    fi
+
+    if test "$OS_RELEASE" = "B.10.10"; then
         cat >> confdefs.h <<\EOF
 #define HPUX10 1
 EOF
 
         cat >> confdefs.h <<\EOF
 #define HPUX10_10 1
 EOF
 
-        cat >> confdefs.h <<\EOF
-#define HAVE_INT_LOCALTIME_R 1
-EOF
-
-        USE_PTHREADS=1
-        USE_NSPR_THREADS=
-        ;;
-    hpuxB.10.20*)
+        DEFAULT_IMPL_STRATEGY=_PTH
+    fi
+
+    if test "$OS_RELEASE" = "B.10.20"; then
         cat >> confdefs.h <<\EOF
 #define HPUX10 1
 EOF
 
         cat >> confdefs.h <<\EOF
 #define HPUX10_20 1
 EOF
 
-        cat >> confdefs.h <<\EOF
-#define HAVE_INT_LOCALTIME_R 1
-EOF
-
-        if test -z "$GNU_CC"; then
+        if test -z "$GNU_CC" && test 0 = 1; then
             CFLAGS="$CFLAGS +DAportable +DS1.1"
             CXXFLAGS="$CXXFLAGS +DAportable +DS1.1"
         fi
-        USE_PTHREADS=1
-        USE_NSPR_THREADS=
-        ;;
-    hpuxB.10.30*)
+        DEFAULT_IMPL_STRATEGY=_EMU
+    fi
+
+    if test "$OS_RELEASE" = "B.10.30"; then
         cat >> confdefs.h <<\EOF
-#define HAVE_POINTER_LOCALTIME_R 1
-EOF
-
-        if test -z "$GNU_CC"; then
+#define HPUX10 1
+EOF
+
+        cat >> confdefs.h <<\EOF
+#define HPUX10_30 1
+EOF
+
+        #CXX="/opt/aCC/bin/aCC -ext"
+        if test -z "$GNU_CC" && test 0 = 1; then
             CFLAGS="$CFLAGS +DAportable +DS1.1"
             CXXFLAGS="$CXXFLAGS +DAportable +DS1.1"
         fi
-        USE_PTHREADS=1
-        USE_NSPR_THREADS=
-        ;;
-    hpuxB.11.00*)
+        DEFAULT_IMPL_STRATEGY=_PTH
+    fi
+
+    if test "$OS_RELEASE" = "B.11.00"; then
         cat >> confdefs.h <<\EOF
 #define HPUX10 1
 EOF
 
         cat >> confdefs.h <<\EOF
 #define HPUX11 1
 EOF
 
@@ -2694,41 +3036,41 @@ EOF
 #define _PR_HAVE_OFF64_T 1
 EOF
 
         cat >> confdefs.h <<\EOF
 #define HAVE_POINTER_LOCALTIME_R 1
 EOF
 
         if test -z "$GNU_CC"; then
+            if test 0 = 1; 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
         fi
+        DEFAULT_IMPL_STRATEGY=_PTH
+    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
-        USE_NSPR_THREADS=
-        ;;
-    esac
-    case "${target_os}" in
-    hpuxB.10*)
-        cat >> confdefs.h <<\EOF
-#define _PR_NO_LARGE_FILES 1
-EOF
-
-        ;;
-    esac
-    if test -n "$USE_NSPR_THREADS"; then
-        cat >> confdefs.h <<\EOF
-#define _PR_LOCAL_THREADS_ONLY 1
-EOF
-
+        if test "$MOZILLA_CLIENT"; then
+            USE_PTHREADS=
+        fi
+        if test "$USE_USER_PTHREADS"; then
+            USE_PTHREADS=
+        fi
     fi
     ;;
 
 *-irix*)
     cat >> confdefs.h <<\EOF
 #define XP_UNIX 1
 EOF
 
@@ -2741,58 +3083,61 @@ EOF
 EOF
 
     cat >> confdefs.h <<\EOF
 #define _SGI_MP_SOURCE 1
 EOF
 
     PR_MD_CSRCS=irix.c
     PR_MD_ASFILES=os_Irix.s
-    MKSHLIB='$(LD) $(SHLIB_LD_OPTS) -rdata_shared -shared -soname $(notdir $@) -o $@'
-    DSO_LDOPTS='-elf -shared -all'
+    MKSHLIB='$(LD) $(DSO_LDOPTS) -rdata_shared -shared -soname $(notdir $@) -o $@'
+    #DSO_LDOPTS='-elf -shared -all'
     if test -n "$USE_64"; then
         MDCPUCFG_H=_irix64.cfg
     else
         MDCPUCFG_H=_irix32.cfg
     fi
     case "${target_os}" in
     irix5*)
 	   USE_NSPR_THREADS=1
 	   ;;
     *)
-	   USE_N32=1
 	   USE_PTHREADS=1
 	   ;;
  	esac
     if test "$GNU_CC"; then
 	    AS='$(CC) -x assembler-with-cpp -D_ASM -mips2 $(INCLUDES)'
 	    CFLAGS="$CFLAGS -Wall -Wno-format"
 	    _OPTIMIZE_FLAGS="-O6"
     else
-	    AS="as -D_ASM $(INCLUDES) -n32"
+	    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"
 	    fi
 	    case "$target}" in
 	    *-irix6.*)
 	        CFLAGS="$CFLAGS -multigot"
-	        SHLIB_LD_OPTS="-no_unresolved"
-	        if test "USE_N32"; then
+	        DSO_LDOPTS="-no_unresolved"
+	        if test "$USE_N32"; then
 		        CFLAGS="$CFLAGS -n32 -woff 1209"
 		        LDFLAGS="$LDFLAGS -n32"
-		        SHLIB_LD_OPTS="$SHLIB_LD_OPTS -n32"
+		        DSO_LDOPTS="$DSO_LDOPTS -n32"
 		        if test "${target_os}" = "irix6.2"; then
 		            LDFLAGS="$LDFLAGS -Wl,-woff,85"
-		            SHLIB_LD_OPTS="$SHLIB_LD_OPTS -woff 85"
+		            DSO_LDOPTS="$DSO_LDOPTS -woff 85"
 		        fi
 	        else
 		        if test "$USE_64"; then
 		            CFLAGS="$CFLAGS -64"
 		        else
 		            CFLAGS="$CFLAGS -32"
 		        fi
 	        fi
@@ -2886,111 +3231,636 @@ EOF
         cat >> confdefs.h <<\EOF
 #define __alpha 1
 EOF
 
         CFLAGS="$CFLAGS -mieee"
         CXXFLAGS="$CXXFLAGS -mieee"
         _OPTIMIZE_FLAGS=-O2
         ;;
+    i?86)
+        PR_MD_ASFILES=os_Linux_x86.s
+        _OPTIMIZE_FLAGS=-O2
+        ;;
     m68k)
         _OPTIMIZE_FLAGS=-O
         CFLAGS="$CFLAGS -m68020-40"
         CXXFLAGS="$CXXFLAGS -m68020-40"
         ;;
     *)
         _OPTIMIZE_FLAGS=-O2
         ;;
     esac    
     ;;
 
-*-mingw*)
+*-mingw*|*-cygwin*|*-msvc*)
     cat >> confdefs.h <<\EOF
 #define XP_PC 1
 EOF
 
     cat >> confdefs.h <<\EOF
-#define NONAMELESSUNION 1
+#define WIN32 1
 EOF
 
     PR_MD_ARCH_DIR=windows
-    if test -z "$GNU_CC"; then
+
+    if test -n "$GNU_CC"; then
+        cat >> confdefs.h <<\EOF
+#define NONAMELESSUNION 1
+EOF
+
+        MKSHLIB='$(DLLTOOL) --as=$(AS) -k --dllname $*.dll --output-lib $@'
+    else
+        CC=cl
+        CXX=cl
+        LD=link
+        AR='lib -NOLOGO -OUT:"$@"'
+        AR_FLAGS=
+        RANLIB='echo not_ranlib'
+        STRIP='echo not_strip'
+        NSINSTALL=nsinstall
+        RC=rc.exe
+        GARBAGE='$(OBJDIR)/vc20.pdb $(OBJDIR)/vc40.pdb'
 	    OBJ_SUFFIX=obj
 	    LIB_SUFFIX=lib
 	    DLL_SUFFIX=dll
+        
+        CFLAGS="$CFLAGS -W3 -nologo -GF -Gy"
+        _DEBUG_FLAGS=
+
+        if test -n "$MOZ_OPTIMIZE"; then
+            CFLAGS="$CFLAGS -MD"
+            OPTIMIZER=-O2
+            DLLFLAGS='-OUT:"$@"'
+            OBJDIR_TAG=_OPT
+
+            if test -n "$MOZ_PROFILE"; then
+                OPTIMIZER="$OPTIMIZER -Z7"
+                DLLFLAGS="$DLLFLAGS -DEBUG -DEBUGTYPE:CV"
+                LDFLAGS="$LDFLAGS -DEBUG -DEBUGTYPE:CV"
     fi
-    MKSHLIB='$(DLLTOOL) --as=$(AS) -k --dllname $*.dll --output-lib $@'
-
-    case "$MOZ_TARGET" in
+        else
+            if test -n "$USE_DEBUG_RTL"; then
+                CFLAGS="$CFLAGS -MDd"
+            else
+                CFLAGS="$CFLAGS -MD"
+            fi
+            OPTIMIZER="-Od -Z7"
+            DLLFLAGS='-DEBUG -DEBUGTYPE:CV -OUT:"$@"'
+            if test -n "$GLOWCODE"; then
+                DLLFLAGS='-DEBUG -DEBUGTYPE:both -INCLUDE:_GlowCode -OUT:"$@"'
+            fi
+            OBJDIR_TAG=_DBG
+            LDFLAGS="$LDFLAGS -DEBUG -DEBUGTYPE:CV"
+            if test -n "$PROFILE"; then
+                LDFLAGS="$LDFLAGS -PROFILE -MAP"
+                DLLFLAGS="$DLLFLAGS -PROFILE -MAP"
+            fi
+        fi
+    fi
+
+    if test -n "$USE_STATIC_TLS"; then
+        cat >> confdefs.h <<\EOF
+#define _PR_USE_STATIC_TLS 1
+EOF
+
+    fi
+
+    if test "$OS_TARGET" = "WINNT"; then
+        if test -z "$GNU_CC"; then
+            CFLAGS="$CFLAGS -GT"
+        fi
+        if test "$CPU_ARCH" = "x86"; then
+            CFLAGS="$CFLAGS -G5"
+        fi
+        cat >> confdefs.h <<\EOF
+#define WINNT 1
+EOF
+
+    else
+        cat >> confdefs.h <<\EOF
+#define WIN95 1
+EOF
+
+        cat >> confdefs.h <<\EOF
+#define _PR_GLOBAL_THREADS_ONLY 1
+EOF
+
+    fi
+
+    if test "$CPU_ARCH" = "x86"; then
+        CPU_ARCH_TAG=
+    else
+        CPU_ARCH_TAG=$CPU_ARCH
+    fi
+
+    if test -n "$USE_DEBUG_RTL"; then
+        OBJDIR_SUFFIX=OBJD
+    else
+        OBJDIR_SUFFIX=OBJ
+    fi
+
+    OBJDIR_NAME="${OS_CONFIG}${CPU_ARCH_TAG}${OBJDIR_TAG}.${OBJDIR_SUFFIX}"
+    OBJDIR='${OBJDIR_NAME}'
+
+    OS_DLLFLAGS='-nologo -DLL -SUBSYSTEM:WINDOWS -PDB:NONE'
+
+    case "$MOZ_WIN32_TARGET" in
     WINNT)
-	    DEFINES="$DEFINES -DWIN32 -DWINNT -DWin32_Winsock"
 	    MDCPUCFG_H=_winnt.cfg
 	    ;;
     WIN95)
-	    DEFINES="$DEFINES -UWINNT -DWIN32 -DWIN95 -DWin32_Winsock -D_PR_GLOBAL_THREADS_ONLY"
 	    MDCPUCFG_H=_win95.cfg
 	    ;;
     WIN16)
-	    DEFINES="$DEFINES -UWINNT"
 	    MDCPUCFG_H=_win16.cfg
 	    ;;
     *)
-	    { echo "configure: error: Missing MOZ_TARGET for ${target}.  Use --enable-target to set." 1>&2; exit 1; }
+	    { echo "configure: error: Missing MOZ_WIN32_TARGET for ${target}.  Use --enable-win32-target to set." 1>&2; exit 1; }
    	;;
     esac
 
-    case "$target" in
-    i?86-*)
+    case "$target_cpu" in
+    i?86)
 	    cat >> confdefs.h <<\EOF
 #define _X86_ 1
 EOF
 
         ;;
-    alpha-*)
+    alpha)
 	    cat >> confdefs.h <<\EOF
 #define _ALPHA_ 1
 EOF
 
    	    ;;
-    mips-*)
+    mips)
 	    cat >> confdefs.h <<\EOF
 #define _MIPS_ 1
 EOF
 
 	    ;;
     *)
 	    cat >> confdefs.h <<\EOF
 #define _CPU_ARCH_NOT_DEFINED 1
 EOF
 
 	    ;;
     esac
+
     ;;
 
+*-ncr-sysv*)
+    cat >> confdefs.h <<\EOF
+#define XP_UNIX 1
+EOF
+
+    cat >> confdefs.h <<\EOF
+#define SVR4 1
+EOF
+
+    cat >> confdefs.h <<\EOF
+#define SYSV 1
+EOF
+
+    cat >> confdefs.h <<\EOF
+#define NCR 1
+EOF
+
+    USE_NSPR_THREADS=1
+    if test "$OS_RELEASE" = "2.03"; then
+        cat >> confdefs.h <<\EOF
+#define _PR_STAT_HAS_ST_ATIM 1
+EOF
+
+    else
+        cat >> confdefs.h <<\EOF
+#define _PR_STAT_HAS_ST_ATIM_UNION 1
+EOF
+
+    fi
+
+    if test -z "$GNU_CC"; then
+        CFLAGS="$CFLAGS -Hnocopyr"
+        CXXFLAGS="$CXXFLAGS -Hnocopyr"
+    else
+        CFLAGS="$CFLAGS -fPIC -Wall -pipe"
+        CXXFLAGS="$CXXFLAGS -fPIC -Wall -pipe"
+        DSO_LDOPTS=-G
+    fi
+    ;;
+
+mips-nec-sysv*)
+    cat >> confdefs.h <<\EOF
+#define XP_UNIX 1
+EOF
+
+    cat >> confdefs.h <<\EOF
+#define SVR4 1
+EOF
+
+    cat >> confdefs.h <<\EOF
+#define __SVR4 1
+EOF
+
+    cat >> confdefs.h <<\EOF
+#define NEC 1
+EOF
+
+    cat >> confdefs.h <<\EOF
+#define nec_ews 1
+EOF
+
+    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*)
+    cat >> confdefs.h <<\EOF
+#define XP_UNIX 1
+EOF
+
+    cat >> confdefs.h <<\EOF
+#define NETBSD 1
+EOF
+
+    cat >> confdefs.h <<\EOF
+#define HAVE_BSD_FLOCK 1
+EOF
+
+    if test -z "$OBJECT_FMT"; then
+        if echo __ELF__ | ${CC-cc} -E - | grep -q __ELF__ 2>/dev/null; then
+            OBJECT_FMT=a.out;
+        else
+            OBJECT_FMT=ELF
+        fi
+    fi
+    if test "$OBJECT_FMT" = "ELF"; then
+        DLL_SUFFIX=so
+    else
+        DLL_SUFFIX=so.1.0
+    fi
+    CFLAGS="$CFLAGS -ansi -Wall -pipe"
+    CXXFLAGS="$CXXFLAGS -ansi -Wall -pipe"
+    DSO_CFLAGS='-fPIC -DPIC'
+    DSO_LDOPTS='-x -shared'
+    if test "$LIBRUNPATH"; then
+        DSO_LDOPTS="$DSO_LDOPTS -R$(LIBRUNPATH)"
+    fi
+    ;;
+
+mips-sony-newsos*)
+    cat >> confdefs.h <<\EOF
+#define XP_UNIX 1
+EOF
+
+    cat >> confdefs.h <<\EOF
+#define SONY 1
+EOF
+
+    cat >> confdefs.h <<\EOF
+#define SYSV 1
+EOF
+
+    cat >> confdefs.h <<\EOF
+#define SVR4 1
+EOF
+
+    cat >> confdefs.h <<\EOF
+#define __svr4 1
+EOF
+
+    cat >> confdefs.h <<\EOF
+#define __svr4__ 1
+EOF
+
+    cat >> confdefs.h <<\EOF
+#define HAVE_SVID_GETTOD 1
+EOF
+
+    USE_NSPR_THREADS=1
+    CFLAGS="$CFLAGS -Xa -fullwarn"
+    CXXFLAGS="$CXXFLAGS -Xa -fullwarn"
+    DSO_LDOPTS=-G
+    ;;
+
+*-nextstep*|*-openstep*)
+    cat >> confdefs.h <<\EOF
+#define XP_UNIX 1
+EOF
+
+    cat >> confdefs.h <<\EOF
+#define NEXTSTEP 1
+EOF
+
+    cat >> confdefs.h <<\EOF
+#define HAVE_BSD_FLOCK 1
+EOF
+
+    cat >> confdefs.h <<\EOF
+#define _POSIX_SOURCE 1
+EOF
+
+    CFLAGS="$CFLAGS -Wall -fno-common -pipe -traditional-cpp -posix"
+    CXXFLAGS="$CXXFLAGS -Wall -fno-common -pipe -traditional-cpp -posix"
+    USE_NSPR_THREADS=1
+    DLL_SUFFIX=dylib
+    ;;
+
+
 *-nto*)
     cat >> confdefs.h <<\EOF
 #define XP_UNIX 1
 EOF
 
+    cat >> confdefs.h <<\EOF
+#define NTO 1
+EOF
+
+    cat >> confdefs.h <<\EOF
+#define _QNX_SOURCE 1
+EOF
+
+    cat >> confdefs.h <<\EOF
+#define HAVE_POINTER_LOCALTIME_R 1
+EOF
+
     MDCPUCFG_H=_nto.cfg
     PR_MD_CSRCS=nto.c
-    MKSHLIB='qcc -Vgcc_ntox86 -shared -Wl,-h$(@:$(OBJDIR)/%.so=%.so) -o $(@:$(OBJDIR)/%.so=%.so)'
-    CFLAGS="$CFLAGS -Wc,-Wall -Wc,-Wno-parentheses -DNTO -D_QNX_SOURCE -DHAVE_POINTER_LOCALTIME_R -shared"
-    OS_LIBS="-lsocket"
-    _OPTIMIZE_FLAGS="-O2"
-    _DEBUG_FLAGS="-O2 -gdwarf-2"
+    MKSHLIB='qcc -Vgcc_ntox86 -shared -Wl,-h$(@:$(OBJDIR)/%.so=%.so) -M -o $(@:$(OBJDIR)/%.so=%.so)'
+    CFLAGS="$CFLAGS -Wc,-Wall -Wc,-Wno-parentheses -shared"
+    OS_LIBS="$OS_LIBS -lsocket"
+    _OPTIMIZE_FLAGS="-O1"
+    _DEBUG_FLAGS="-O1 -gstabs"
     COMPILER_TAG="_qcc"
     CC="qcc -Vgcc_ntox86 -w"
-    CXX="QCC -Vgcc_ntox86 -w"
-    CPP="qcc -Vgcc_ntox86 -w"
+    CXX='$(CC)'
     LD="qcc -Vgcc_ntox86 -nostdlib"
-    AR="qcc -Vgcc_ntox86 -M -a "
-    AR_FLAGS="$@"
+    AR="qcc -Vgcc_ntox86 -M -a $@"
+    AR_FLAGS=
 	;;
 
+*-openbsd*)
+    cat >> confdefs.h <<\EOF
+#define XP_UNIX 1
+EOF
+
+    cat >> confdefs.h <<\EOF
+#define OPENBSD 1
+EOF
+
+    cat >> confdefs.h <<\EOF
+#define HAVE_BSD_FLOCK 1
+EOF
+
+    CFLAGS="$CFLAGS -ansi -Wall -pipe"
+    CXXFLAGS="$CXXFLAGS -ansi -Wall -pipe"
+    DLL_SUFFIX=so.1.0
+    DSO_CFLAGS=-fPIC
+    case "$OS_TEST" in
+    alpha|mips|pmax)
+        DSO_LDOPTS=-shared ;;
+    *)
+        DSO_LDOPTS=-Bshareable ;;
+    esac
+    ;;
+
+*-openvms*)
+    cat >> confdefs.h <<\EOF
+#define XP_UNIX 1
+EOF
+
+    cat >> confdefs.h <<\EOF
+#define VMS 1
+EOF
+
+    cat >> confdefs.h <<\EOF
+#define VMS_AS_IS 1
+EOF
+
+    cat >> confdefs.h <<\EOF
+#define GENERIC_PTHREAD_REDEFINES 1
+EOF
+
+    CROSS_COMPILE=1
+    HOST_CC=c89
+    HOST_CXX=cxx
+    HOST_CFLAGS=-O
+    HOST_CXXFLAGS=-O
+    CFLAGS="$CFLAGS -Wc,names=\(short,as\)"
+    CXXFLAGS="$CXXFLAGS -Wc,names=\(short,as\)"
+    MKSHLIB='vmsld $(OPTIMIZER)'
+    ;;
+
+*-osf1*)
+    cat >> confdefs.h <<\EOF
+#define XP_UNIX 1
+EOF
+
+    cat >> confdefs.h <<\EOF
+#define OSF1 1
+EOF
+
+
+    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='-Olimit 4000'
+    fi
+
+    if echo $OS_RELEASE | egrep -c '(V2.0|V3.2)' 2>/dev/null; then
+        cat >> confdefs.h <<\EOF
+#define HAVE_INT_LOCALTIME_R 1
+EOF
+
+    else
+        cat >> confdefs.h <<\EOF
+#define HAVE_POINTER_LOCALTIME_R 1
+EOF
+
+        cat >> confdefs.h <<\EOF
+#define OSF1_HAVE_MACHINE_BUILTINS_H 1
+EOF
+
+    fi
+    DSO_LDOPTS='-shared -all -expect_unresolved "*" -soname $(notdir $@)'
+    ;;
+
+*-qnx*)
+    cat >> confdefs.h <<\EOF
+#define XP_UNIX 1
+EOF
+
+    cat >> confdefs.h <<\EOF
+#define QNX 1
+EOF
+
+    cat >> confdefs.h <<\EOF
+#define _PR_NEED_H_ERRNO 1
+EOF
+
+    USE_NSPR_THREADS=1
+    ;;
+
+*-rhapsody*)
+    cat >> confdefs.h <<\EOF
+#define XP_UNIX 1
+EOF
+
+    cat >> confdefs.h <<\EOF
+#define RHAPSODY 1
+EOF
+
+    cat >> confdefs.h <<\EOF
+#define HAVE_BSD_FLOCK 1
+EOF
+
+    CFLAGS="$CFLAGS -Wmost -fno-common -pipe"    
+    if echo $OS_TEST | grep -c 86 2>/dev/null; then
+        CFLAGS="$CFLAGS -mno-486"
+        cat >> confdefs.h <<\EOF
+#define i386 1
+EOF
+
+        CPU_ARCH=i386
+    else
+        cat >> confdefs.h <<\EOF
+#define ppc 1
+EOF
+
+        CPU_ARCH=ppc
+    fi
+    DSO_LDOPTS='-dynamiclib -compatibility_version 1 -current_version 1 -all_load'
+    MKSHLIB='$(CC) -arch $(CPU_ARCH) $(DSO_LDOPTS) -o $@'
+    DLL_SUFFIX=dylib
+    USE_PTHREADS=1
+    ;;
+
+*-*-sco*)
+    cat >> confdefs.h <<\EOF
+#define XP_UNIX 1
+EOF
+
+    cat >> confdefs.h <<\EOF
+#define SCO 1
+EOF
+
+    cat >> confdefs.h <<\EOF
+#define sco 1
+EOF
+
+    cat >> confdefs.h <<\EOF
+#define SYSV 1
+EOF
+
+    cat >> confdefs.h <<\EOF
+#define _SVID3 1
+EOF
+
+    cat >> confdefs.h <<\EOF
+#define _PR_NEED_H_ERRNO 1
+EOF
+
+    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*)
+    cat >> confdefs.h <<\EOF
+#define XP_UNIX 1
+EOF
+
+    cat >> confdefs.h <<\EOF
+#define SVR4 1
+EOF
+
+    cat >> confdefs.h <<\EOF
+#define SNI 1
+EOF
+
+    cat >> confdefs.h <<\EOF
+#define RELIANTUNIX 1
+EOF
+
+    cat >> confdefs.h <<\EOF
+#define sinix 1
+EOF
+
+    cat >> confdefs.h <<\EOF
+#define HAVE_SVID_GETTOD 1
+EOF
+
+    if echo "$OS_TEST" | grep -c 86 2>/dev/null; then
+        cat >> confdefs.h <<\EOF
+#define i386 1
+EOF
+
+        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
+            CFLAGS="$CFLAGS -pipe"
+        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
+        cat >> confdefs.h <<\EOF
+#define IP_MULTICAST 1
+EOF
+
+    fi
+
+    OS_LIBS="$OS_LIBS -lsocket -lnsl -lresolv -ldl -lc"
+    USE_NSPR_THREADS=1
+    ;;
+
+*-sunos*)
+    cat >> confdefs.h <<\EOF
+#define XP_UNIX 1
+EOF
+
+    cat >> confdefs.h <<\EOF
+#define SUNOS4 1
+EOF
+
+    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
+    ;;
+
 *-solaris*)
     cat >> confdefs.h <<\EOF
 #define XP_UNIX 1
 EOF
 
     cat >> confdefs.h <<\EOF
 #define SVR4 1
 EOF
@@ -3022,35 +3892,34 @@ EOF
         DSO_CFLAGS=-fPIC
     else
         DSO_CFLAGS=-KPIC
     fi
     AS='$(CC)'
     if test -z "$GNU_AS"; then
         ASFLAGS="$ASFLAGS -Wa,-P"
     fi
-    NOSUCHFILE=/no-such-file
     if test -n "$GNU_CC"; then
         if test -n "$USE_MDUPDATE"; then
-            CFLAGS="$CFLAGS -MDupdate"
-            CXXFLAGS="$CXXFLAGS -MDupdate"
+            CFLAGS="$CFLAGS -MDupdate \$(DEPENDENCIES)"
+            CXXFLAGS="$CXXFLAGS -MDupdate \$(DEPENDENCIES)"
         fi
     else
         CC="$CC -xstrconst"
         CXX="$CXX -Qoption cg -xstrconst"
     fi
     if test -n "$BUILD_NUMBER" && test -z "$MOZ_OPTIMIZE"; then
         CFLAGS="$CFLAGS -xs"
         CXXFLAGS="$CXXFLAGS -xs"
     fi
     if test -n "$USE_64" && test -z "$GNU_CC"; then
         CC="$CC -xarch=v9"
         CXX="$CXX -xarch=v9"
     fi
-    if test "${target_cpu}" = "i386"; then
+    if test "$OS_TEST" = "i86pc"; then
         cat >> confdefs.h <<\EOF
 #define i386 1
 EOF
 
         if test -n "$MOZ_DEBUG" && test -n "$GNU_CC"; then
             _DEBUG_FLAGS="$_DEBUG_FLAGS -gstabs"
             if test -z "$GNU_AS"; then
                 _DEBUG_FLAGS="$_DEBUG_FLAGS -Wa,-s"
@@ -3084,96 +3953,231 @@ EOF
         if test -n "$GNU_CC"; then
             cat >> confdefs.h <<\EOF
 #define _LARGEFILE64_SOURCE 1
 EOF
 
         fi
         ;;
     esac
-    if test "${target_cpu}" = "sun4u"; then
+    if test "$OS_TEST" = "sun4u"; then
         ULTRASPARC_LIBRARY=ultrasparc
         ULTRASPARC_FILTER_LIBRARY=libatomic.so
         DSO_LDOPTS="$DSO_LDOPTS -f "'$(ULTRASPARC_FILTER_LIBRARY)'
     fi
     ;;
 
+*-sco-sysv5*)
+    cat >> confdefs.h <<\EOF
+#define XP_UNIX 1
+EOF
+
+    cat >> confdefs.h <<\EOF
+#define UNIXWARE 1
+EOF
+
+    cat >> confdefs.h <<\EOF
+#define SVR4 1
+EOF
+
+    cat >> confdefs.h <<\EOF
+#define SYSV 1
+EOF
+
+    USE_NSPR_THREADS=1
+    if echo $OS_RELEASE | grep -c 2.1 2>/dev/null; then
+        cat >> confdefs.h <<\EOF
+#define _PR_NO_LARGE_FILES 1
+EOF
+
+        CC='$(NSDEPTH)/build/hcc cc'
+        CXX='$(NSDEPTH)/build/hcpp CC'
+    else
+        cat >> confdefs.h <<\EOF
+#define _LARGEFILE64_SOURCE 1
+EOF
+
+        cat >> confdefs.h <<\EOF
+#define _PR_HAVE_OFF64_T 1
+EOF
+
+        cat >> confdefs.h <<\EOF
+#define _PR_HAVE_SOCKADDR_LEN 1
+EOF
+
+    fi
+    DSO_LDOPTS=-G
+    CPU_ARCH=x86
+    ;;
+
 *)
     cat >> confdefs.h <<\EOF
 #define XP_UNIX 1
 EOF
 
     ;;
    
 esac
 
 if test "$enable_shared" = no; then
     MKSHLIB=
 fi
 
+if test -z "$SKIP_LIBRARY_CHECKS"; then
+
+echo $ac_n "checking for dlopen""... $ac_c" 1>&6
+echo "configure:4028: checking for dlopen" >&5
+if eval "test \"`echo '$''{'ac_cv_func_dlopen'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  cat > conftest.$ac_ext <<EOF
+#line 4033 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char dlopen(); below.  */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error.  */
+/* We use char because int might match the return type of a gcc2
+    builtin and then its argument prototype would still apply.  */
+char dlopen();
+
+int main() {
+
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined (__stub_dlopen) || defined (__stub___dlopen)
+choke me
+#else
+dlopen();
+#endif
+
+; return 0; }
+EOF
+if { (eval echo configure:4056: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+  rm -rf conftest*
+  eval "ac_cv_func_dlopen=yes"
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  eval "ac_cv_func_dlopen=no"
+fi
+rm -f conftest*
+fi
+
+if eval "test \"`echo '$ac_cv_func_'dlopen`\" = yes"; then
+  echo "$ac_t""yes" 1>&6
+  :
+else
+  echo "$ac_t""no" 1>&6
+
+    echo $ac_n "checking for dlopen in -ldl""... $ac_c" 1>&6
+echo "configure:4075: checking for dlopen in -ldl" >&5
+ac_lib_var=`echo dl'_'dlopen | sed 'y%./+-%__p_%'`
+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  ac_save_LIBS="$LIBS"
+LIBS="-ldl  $LIBS"
+cat > conftest.$ac_ext <<EOF
+#line 4083 "configure"
+#include "confdefs.h"
+/* Override any gcc2 internal prototype to avoid an error.  */
+/* We use char because int might match the return type of a gcc2
+    builtin and then its argument prototype would still apply.  */
+char dlopen();
+
+int main() {
+dlopen()
+; return 0; }
+EOF
+if { (eval echo configure:4094: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+  rm -rf conftest*
+  eval "ac_cv_lib_$ac_lib_var=yes"
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  eval "ac_cv_lib_$ac_lib_var=no"
+fi
+rm -f conftest*
+LIBS="$ac_save_LIBS"
+
+fi
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+  echo "$ac_t""yes" 1>&6
+  OS_LIBS="-ldl $OS_LIBS"
+else
+  echo "$ac_t""no" 1>&6
+fi
+
+
+fi
+
 
 
 
 echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
-echo "configure:3117: checking how to run the C preprocessor" >&5
+echo "configure:4121: checking how to run the C preprocessor" >&5
 # On Suns, sometimes $CPP names a directory.
 if test -n "$CPP" && test -d "$CPP"; then
   CPP=
 fi
 if test -z "$CPP"; then
 if eval "test \"`echo '$''{'ac_cv_prog_CPP'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
     # This must be in double quotes, not single quotes, because CPP may get
   # substituted into the Makefile and "${CC-cc}" will confuse make.
   CPP="${CC-cc} -E"
   # On the NeXT, cc -E runs the code through the compiler's parser,
   # not just through cpp.
   cat > conftest.$ac_ext <<EOF
-#line 3132 "configure"
+#line 4136 "configure"
 #include "confdefs.h"
 #include <assert.h>
 Syntax Error
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:3138: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:4142: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   :
 else
   echo "$ac_err" >&5
   echo "configure: failed program was:" >&5
   cat conftest.$ac_ext >&5
   rm -rf conftest*
   CPP="${CC-cc} -E -traditional-cpp"
   cat > conftest.$ac_ext <<EOF
-#line 3149 "configure"
+#line 4153 "configure"
 #include "confdefs.h"
 #include <assert.h>
 Syntax Error
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:3155: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:4159: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   :
 else
   echo "$ac_err" >&5
   echo "configure: failed program was:" >&5
   cat conftest.$ac_ext >&5
   rm -rf conftest*
   CPP="${CC-cc} -nologo -E"
   cat > conftest.$ac_ext <<EOF
-#line 3166 "configure"
+#line 4170 "configure"
 #include "confdefs.h"
 #include <assert.h>
 Syntax Error
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:3172: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:4176: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   :
 else
   echo "$ac_err" >&5
   echo "configure: failed program was:" >&5
   cat conftest.$ac_ext >&5
   rm -rf conftest*
@@ -3189,23 +4193,23 @@ fi
   CPP="$ac_cv_prog_CPP"
 else
   ac_cv_prog_CPP="$CPP"
 fi
 echo "$ac_t""$CPP" 1>&6
 
 if test $ac_cv_prog_gcc = yes; then
     echo $ac_n "checking whether ${CC-cc} needs -traditional""... $ac_c" 1>&6
-echo "configure:3198: checking whether ${CC-cc} needs -traditional" >&5
+echo "configure:4202: checking whether ${CC-cc} needs -traditional" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_gcc_traditional'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
     ac_pattern="Autoconf.*'x'"
   cat > conftest.$ac_ext <<EOF
-#line 3204 "configure"
+#line 4208 "configure"
 #include "confdefs.h"
 #include <sgtty.h>
 Autoconf TIOCGETP
 EOF
 if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
   egrep "$ac_pattern" >/dev/null 2>&1; then
   rm -rf conftest*
   ac_cv_prog_gcc_traditional=yes
@@ -3213,17 +4217,17 @@ else
   rm -rf conftest*
   ac_cv_prog_gcc_traditional=no
 fi
 rm -f conftest*
 
 
   if test $ac_cv_prog_gcc_traditional = no; then
     cat > conftest.$ac_ext <<EOF
-#line 3222 "configure"
+#line 4226 "configure"
 #include "confdefs.h"
 #include <termio.h>
 Autoconf TCGETA
 EOF
 if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
   egrep "$ac_pattern" >/dev/null 2>&1; then
   rm -rf conftest*
   ac_cv_prog_gcc_traditional=yes
@@ -3237,22 +4241,22 @@ echo "$ac_t""$ac_cv_prog_gcc_traditional
   if test $ac_cv_prog_gcc_traditional = yes; then
     CC="$CC -traditional"
   fi
 fi
 
 for ac_func in lchown strerror
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:3246: checking for $ac_func" >&5
+echo "configure:4250: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3251 "configure"
+#line 4255 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
 #include <assert.h>
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
     builtin and then its argument prototype would still apply.  */
 char $ac_func();
@@ -3265,17 +4269,17 @@ int main() {
 #if defined (__stub_$ac_func) || defined (__stub___$ac_func)
 choke me
 #else
 $ac_func();
 #endif
 
 ; return 0; }
 EOF
-if { (eval echo configure:3274: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:4278: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
   echo "configure: failed program was:" >&5
   cat conftest.$ac_ext >&5
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=no"
 fi
@@ -3292,139 +4296,120 @@ EOF
 else
   echo "$ac_t""no" 1>&6
 fi
 done
 
 
 
 
-echo $ac_n "checking for pthread_attr_init in -lpthread""... $ac_c" 1>&6
-echo "configure:3302: checking for pthread_attr_init in -lpthread" >&5
-ac_lib_var=`echo pthread'_'pthread_attr_init | sed 'y%./+-%__p_%'`
-if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
-else
-  ac_save_LIBS="$LIBS"
-LIBS="-lpthread  $LIBS"
-cat > conftest.$ac_ext <<EOF
-#line 3310 "configure"
-#include "confdefs.h"
-/* Override any gcc2 internal prototype to avoid an error.  */
-/* We use char because int might match the return type of a gcc2
-    builtin and then its argument prototype would still apply.  */
-char pthread_attr_init();
-
-int main() {
-pthread_attr_init()
-; return 0; }
-EOF
-if { (eval echo configure:3321: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
-  rm -rf conftest*
-  eval "ac_cv_lib_$ac_lib_var=yes"
-else
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -rf conftest*
-  eval "ac_cv_lib_$ac_lib_var=no"
-fi
-rm -f conftest*
-LIBS="$ac_save_LIBS"
-
-fi
-if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
-  echo "$ac_t""yes" 1>&6
-  _HAVE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthread"
-else
-  echo "$ac_t""no" 1>&6
-echo $ac_n "checking for pthread_attr_init in -lc_r""... $ac_c" 1>&6
-echo "configure:3340: checking for pthread_attr_init in -lc_r" >&5
-ac_lib_var=`echo c_r'_'pthread_attr_init | sed 'y%./+-%__p_%'`
-if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
-else
-  ac_save_LIBS="$LIBS"
-LIBS="-lc_r  $LIBS"
-cat > conftest.$ac_ext <<EOF
-#line 3348 "configure"
-#include "confdefs.h"
-/* Override any gcc2 internal prototype to avoid an error.  */
-/* We use char because int might match the return type of a gcc2
-    builtin and then its argument prototype would still apply.  */
-char pthread_attr_init();
-
-int main() {
-pthread_attr_init()
-; return 0; }
-EOF
-if { (eval echo configure:3359: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
-  rm -rf conftest*
-  eval "ac_cv_lib_$ac_lib_var=yes"
-else
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -rf conftest*
-  eval "ac_cv_lib_$ac_lib_var=no"
-fi
-rm -f conftest*
-LIBS="$ac_save_LIBS"
-
-fi
-if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
-  echo "$ac_t""yes" 1>&6
-  _HAVE_PTHREADS=1 _PTHREAD_LDFLAGS="-lc_r"
-else
-  echo "$ac_t""no" 1>&6
-echo $ac_n "checking for pthread_attr_init in -lc""... $ac_c" 1>&6
-echo "configure:3378: checking for pthread_attr_init in -lc" >&5
-ac_lib_var=`echo c'_'pthread_attr_init | sed 'y%./+-%__p_%'`
-if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
-else
-  ac_save_LIBS="$LIBS"
-LIBS="-lc  $LIBS"
-cat > conftest.$ac_ext <<EOF
-#line 3386 "configure"
-#include "confdefs.h"
-/* Override any gcc2 internal prototype to avoid an error.  */
-/* We use char because int might match the return type of a gcc2
-    builtin and then its argument prototype would still apply.  */
-char pthread_attr_init();
-
-int main() {
-pthread_attr_init()
-; return 0; }
-EOF
-if { (eval echo configure:3397: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
-  rm -rf conftest*
-  eval "ac_cv_lib_$ac_lib_var=yes"
-else
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -rf conftest*
-  eval "ac_cv_lib_$ac_lib_var=no"
-fi
-rm -f conftest*
-LIBS="$ac_save_LIBS"
-
-fi
-if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
-  echo "$ac_t""yes" 1>&6
-  _HAVE_PTHREADS=1 
-else
-  echo "$ac_t""no" 1>&6
-fi
+
+
+
+echo $ac_n "checking for pthread_create in -lpthreads""... $ac_c" 1>&6
+echo "configure:4309: checking for pthread_create in -lpthreads" >&5
+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 -lpthreads $LDFLAGS $LIBS" 1>&5;
+    ${CC-cc} -o dummy${ac_exeext} dummy.c $CFLAGS $CPPFLAGS -lpthreads $LDFLAGS $LIBS 2>&5;
+    _res=$? ;
+    rm -f dummy.c dummy${ac_exeext} ;
+    if test "$_res" = "0"; then
+        echo "$ac_t""yes" 1>&6
+        _HAVE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthreads"
+    else
+        echo "$ac_t""no" 1>&6
+        
+echo $ac_n "checking for pthread_create in -lpthread""... $ac_c" 1>&6
+echo "configure:4331: checking for pthread_create in -lpthread" >&5
+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 -lpthread $LDFLAGS $LIBS" 1>&5;
+    ${CC-cc} -o dummy${ac_exeext} dummy.c $CFLAGS $CPPFLAGS -lpthread $LDFLAGS $LIBS 2>&5;
+    _res=$? ;
+    rm -f dummy.c dummy${ac_exeext} ;
+    if test "$_res" = "0"; then
+        echo "$ac_t""yes" 1>&6
+        _HAVE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthread"
+    else
+        echo "$ac_t""no" 1>&6
+        
+echo $ac_n "checking for pthread_create in -lc_r""... $ac_c" 1>&6
+echo "configure:4353: checking for pthread_create in -lc_r" >&5
+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 -lc_r $LDFLAGS $LIBS" 1>&5;
+    ${CC-cc} -o dummy${ac_exeext} dummy.c $CFLAGS $CPPFLAGS -lc_r $LDFLAGS $LIBS 2>&5;
+    _res=$? ;
+    rm -f dummy.c dummy${ac_exeext} ;
+    if test "$_res" = "0"; then
+        echo "$ac_t""yes" 1>&6
+        _HAVE_PTHREADS=1 _PTHREAD_LDFLAGS="-lc_r"
+    else
+        echo "$ac_t""no" 1>&6
+        
+echo $ac_n "checking for pthread_create in -lc""... $ac_c" 1>&6
+echo "configure:4375: checking for pthread_create in -lc" >&5
+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 -lc $LDFLAGS $LIBS" 1>&5;
+    ${CC-cc} -o dummy${ac_exeext} dummy.c $CFLAGS $CPPFLAGS -lc $LDFLAGS $LIBS 2>&5;
+    _res=$? ;
+    rm -f dummy.c dummy${ac_exeext} ;
+    if test "$_res" = "0"; then
+        echo "$ac_t""yes" 1>&6
+        _HAVE_PTHREADS=1
+            
+    else
+        echo "$ac_t""no" 1>&6
+        
+    fi
 
         
-fi
+    fi
 
     
-fi
-
-
+    fi
+
+
+    fi
+
+                        
 # Check whether --with-pthreads or --without-pthreads was given.
 if test "${with_pthreads+set}" = set; then
   withval="$with_pthreads"
    if test "$withval" = "yes"; then
 	    if test -n "$_HAVE_PTHREADS"; then
 		    USE_PTHREADS=1 
 		    USE_USER_PTHREADS=
 		    USE_NSPR_THREADS=
@@ -3493,16 +4478,18 @@ if test "${with_native_threads+set}" = s
 	    USE_USER_PTHREADS=
 	    USE_PTHREADS=
 	  fi
 fi
 
     ;;
 esac
 
+fi # SKIP_LIBRARY_CHECKS
+
 # Check whether --enable-cplus or --disable-cplus was given.
 if test "${enable_cplus+set}" = set; then
   enableval="$enable_cplus"
    if test "$enableval" = "yes"; then
 	    USE_CPLUS=1
       fi
 fi
  
@@ -3511,187 +4498,110 @@ fi
 if test "${enable_ipv6+set}" = set; then
   enableval="$enable_ipv6"
    if test "$enableval" = "yes"; then
 	    USE_IPV6=1
       fi
 fi
 
 
+
+# Check whether --enable-boehm or --disable-boehm was given.
+if test "${enable_boehm+set}" = set; then
+  enableval="$enable_boehm"
+   if test "$enableval" = "yes"; then
+        cat >> confdefs.h <<\EOF
+#define GC_LEAK_DETECTOR 1
+EOF
+
+        GC_LEAK_DETECTOR=1
+    fi
+fi
+
+
 if test -n "$USE_PTHREADS"; then
       rm -f conftest*
    ac_cv_have_dash_pthread=no
    echo $ac_n "checking whether ${CC-cc} accepts -pthread""... $ac_c" 1>&6
-echo "configure:3524: checking whether ${CC-cc} accepts -pthread" >&5
+echo "configure:4525: checking whether ${CC-cc} accepts -pthread" >&5
    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*
     echo "$ac_t""$ac_cv_have_dash_pthread" 1>&6
 
+			    ac_cv_have_dash_pthreads=no
+    if test "$ac_cv_have_dash_pthread" = "no"; then
+	    echo $ac_n "checking whether ${CC-cc} accepts -pthreads""... $ac_c" 1>&6
+echo "configure:4541: checking whether ${CC-cc} accepts -pthreads" >&5
+    	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*
+    	echo "$ac_t""$ac_cv_have_dash_pthreads" 1>&6
+    fi
+
     case "$target" in
-    *-mingw*|*-cygwin*|*-uwin*)
+    *-mingw*|*-cygwin*|*-uwin*|*-msvc*)
 	    ;;
     *-solaris*)
 	    cat >> confdefs.h <<\EOF
 #define _REENTRANT 1
 EOF
 
+        if test "$ac_cv_have_dash_pthreads" = "yes"; then
+            _PTHREAD_LDFLAGS=
+        fi
 	    ;;
-    *-freebsd*)
+    *-freebsd*|*-openbsd*|*-bsdi*|*-netbsd*)
 	    cat >> confdefs.h <<\EOF
 #define _REENTRANT 1
 EOF
 
 	    cat >> confdefs.h <<\EOF
 #define _THREAD_SAFE 1
 EOF
 
 	    	    if test "$ac_cv_have_dash_pthread" = "yes"; then
-	        PTHREAD_LDFLAGS=
+	        _PTHREAD_LDFLAGS=
 	    fi
 	    ;;
-    *-hpuxB.10.10*)
-        cat >> confdefs.h <<\EOF
-#define _REENTRANT 1
-EOF
-
-        cat >> confdefs.h <<\EOF
-#define _PR_DCETHREADS 1
-EOF
-
-        ;;
-    *-hpuxB.10.20*)
-        cat >> confdefs.h <<\EOF
-#define _REENTRANT 1
-EOF
-
-        cat >> confdefs.h <<\EOF
-#define _PR_DCETHREADS 1
-EOF
-
-        ;;
-    *-hpux*)
-        cat >> confdefs.h <<\EOF
-#define _POSIX_C_SOURCE=199506L 1
-EOF
-
-        ;;
     *)
 	    cat >> confdefs.h <<\EOF
 #define _REENTRANT 1
 EOF
 
 	    ;;
     esac
 
-    echo $ac_n "checking for pthread_create""... $ac_c" 1>&6
-echo "configure:3594: checking for pthread_create" >&5
-if eval "test \"`echo '$''{'ac_cv_func_pthread_create'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
-else
-  cat > conftest.$ac_ext <<EOF
-#line 3599 "configure"
-#include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
-    which can conflict with char pthread_create(); below.  */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error.  */
-/* We use char because int might match the return type of a gcc2
-    builtin and then its argument prototype would still apply.  */
-char pthread_create();
-
-int main() {
-
-/* The GNU C library defines this for functions which it implements
-    to always fail with ENOSYS.  Some functions are actually named
-    something starting with __ and the normal name is an alias.  */
-#if defined (__stub_pthread_create) || defined (__stub___pthread_create)
-choke me
-#else
-pthread_create();
-#endif
-
-; return 0; }
-EOF
-if { (eval echo configure:3622: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
-  rm -rf conftest*
-  eval "ac_cv_func_pthread_create=yes"
-else
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -rf conftest*
-  eval "ac_cv_func_pthread_create=no"
-fi
-rm -f conftest*
-fi
-
-if eval "test \"`echo '$ac_cv_func_'pthread_create`\" = yes"; then
-  echo "$ac_t""yes" 1>&6
-  :
-else
-  echo "$ac_t""no" 1>&6
-
-       echo $ac_n "checking for pthread_create in -lpthread""... $ac_c" 1>&6
-echo "configure:3641: checking for pthread_create in -lpthread" >&5
-ac_lib_var=`echo pthread'_'pthread_create | sed 'y%./+-%__p_%'`
-if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
-else
-  ac_save_LIBS="$LIBS"
-LIBS="-lpthread  $LIBS"
-cat > conftest.$ac_ext <<EOF
-#line 3649 "configure"
-#include "confdefs.h"
-/* Override any gcc2 internal prototype to avoid an error.  */
-/* We use char because int might match the return type of a gcc2
-    builtin and then its argument prototype would still apply.  */
-char pthread_create();
-
-int main() {
-pthread_create()
-; return 0; }
-EOF
-if { (eval echo configure:3660: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
-  rm -rf conftest*
-  eval "ac_cv_lib_$ac_lib_var=yes"
-else
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -rf conftest*
-  eval "ac_cv_lib_$ac_lib_var=no"
-fi
-rm -f conftest*
-LIBS="$ac_save_LIBS"
-
-fi
-if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
-  echo "$ac_t""yes" 1>&6
-  OS_LIBS="-lpthread $OS_LIBS"
-else
-  echo "$ac_t""no" 1>&6
-fi
-
-    
-fi
-
-
 else 
     if test -n "$USE_USER_PTHREADS"; then
 	    USE_PTHREADS=
 	    USE_NSPR_THREADS=
     else
-	    USE_NSPR_THREADS=1
-	        fi
+        _PTHREAD_LDFLAGS=
+        if test -n "$USE_NSPR_THREADS"; then
+    	    cat >> confdefs.h <<\EOF
+#define _PR_LOCAL_THREADS_ONLY 1
+EOF
+
+        fi
+    fi
 fi
 
 case "$target" in
 *-aix4.1*)
     if test -z "$USE_PTHREADS"; then
         cat >> confdefs.h <<\EOF
 #define AIX_RENAME_SELECT 1
 EOF
@@ -3701,29 +4611,59 @@ EOF
 *-aix4.23*)
     if test -z "$USE_NSPR_THREADS"; then
         cat >> confdefs.h <<\EOF
 #define HAVE_POINTER_LOCALTIME_R 1
 EOF
 
     fi
     ;;
-*-hpux*)
-    if test -n "$USE_USER_PTHREADS"; then
+*-bsdi*)
+    if test -n "$USE_PTHREADS"; then
         cat >> confdefs.h <<\EOF
-#define _POSIX_C_SOURCE=199506L 1
+#define _PR_NEED_PTHREAD_INIT 1
 EOF
 
     fi
     ;;
-*-mingw*|*-cygwin*|*-uwin*)
+*-hpux*)
+    if test "$USE_PTHREADS"; then
+        if echo "$OS_RELEASE" | egrep '^(B.10.10|B.10.20)' >/dev/null; then
+            cat >> confdefs.h <<\EOF
+#define REENTRANT 1
+EOF
+
+            cat >> confdefs.h <<\EOF
+#define _PR_DCETHREADS 1
+EOF
+
+        else
+            cat >> confdefs.h <<EOF
+#define _POSIX_C_SOURCE 199506L
+EOF
+
+        fi
+    fi
+    if test "$USE_USER_PTHREADS"; then
+        cat >> confdefs.h <<EOF
+#define _POSIX_C_SOURCE 199506L
+EOF
+
+    fi
+    ;;
+*-mingw*|*-cygwin*|*-uwin*|*-msvc*)
         USE_PTHREADS=
-    PTHREAD_LDFLAGS=
+    _PTHREAD_LDFLAGS=
     USE_USER_PTHREADS=
     ;;
+*-netbsd*)
+    if test -z "$USE_PTHREADS"; then
+        OS_LIBS="$OS_LIBS -lc"
+    fi
+    ;;    
 *-solaris*)
     if test -n "$USE_NATIVE_THREADS"; then
         cat >> confdefs.h <<\EOF
 #define _PR_GLOBAL_THREADS_ONLY 1
 EOF
 
     else
         if test -n "$USE_USER_PTHREADS"; then
@@ -3737,119 +4677,34 @@ EOF
         cat >> confdefs.h <<\EOF
 #define _REENTRANT 1
 EOF
 
         cat >> confdefs.h <<\EOF
 #define HAVE_POINTER_LOCALTIME_R 1
 EOF
 
-        if test "${target_cpu}" = "i386"; then
+        if test "$OS_TEST" = "i86pc"; then
             PR_MD_ASFILES=os_SunOS_x86.s
         else
             PR_MD_ASFILES=os_SunOS.s
             if test -z "$USE_64"; then
                 PR_MD_ASFILES="$PR_MD_ASFILES os_SunOS_32.s"
             fi
         fi
     fi
     ;;
 esac
 
-echo $ac_n "checking for dlopen""... $ac_c" 1>&6
-echo "configure:3759: checking for dlopen" >&5
-if eval "test \"`echo '$''{'ac_cv_func_dlopen'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
-else
-  cat > conftest.$ac_ext <<EOF
-#line 3764 "configure"
-#include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
-    which can conflict with char dlopen(); below.  */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error.  */
-/* We use char because int might match the return type of a gcc2
-    builtin and then its argument prototype would still apply.  */
-char dlopen();
-
-int main() {
-
-/* The GNU C library defines this for functions which it implements
-    to always fail with ENOSYS.  Some functions are actually named
-    something starting with __ and the normal name is an alias.  */
-#if defined (__stub_dlopen) || defined (__stub___dlopen)
-choke me
-#else
-dlopen();
-#endif
-
-; return 0; }
-EOF
-if { (eval echo configure:3787: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
-  rm -rf conftest*
-  eval "ac_cv_func_dlopen=yes"
-else
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -rf conftest*
-  eval "ac_cv_func_dlopen=no"
-fi
-rm -f conftest*
+OS_LIBS="$_PTHREAD_LDFLAGS $OS_LIBS"
+
+if test -n "$_SAVE_OPTIMIZE_FLAGS"; then
+    _OPTIMIZE_FLAGS="$_SAVE_OPTIMIZE_FLAGS"
 fi
 
-if eval "test \"`echo '$ac_cv_func_'dlopen`\" = yes"; then
-  echo "$ac_t""yes" 1>&6
-  :
-else
-  echo "$ac_t""no" 1>&6
-
-    echo $ac_n "checking for dlopen in -ldl""... $ac_c" 1>&6
-echo "configure:3806: checking for dlopen in -ldl" >&5
-ac_lib_var=`echo dl'_'dlopen | sed 'y%./+-%__p_%'`
-if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
-else
-  ac_save_LIBS="$LIBS"
-LIBS="-ldl  $LIBS"
-cat > conftest.$ac_ext <<EOF
-#line 3814 "configure"
-#include "confdefs.h"
-/* Override any gcc2 internal prototype to avoid an error.  */
-/* We use char because int might match the return type of a gcc2
-    builtin and then its argument prototype would still apply.  */
-char dlopen();
-
-int main() {
-dlopen()
-; return 0; }
-EOF
-if { (eval echo configure:3825: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
-  rm -rf conftest*
-  eval "ac_cv_lib_$ac_lib_var=yes"
-else
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -rf conftest*
-  eval "ac_cv_lib_$ac_lib_var=no"
-fi
-rm -f conftest*
-LIBS="$ac_save_LIBS"
-
-fi
-if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
-  echo "$ac_t""yes" 1>&6
-  OS_LIBS="-ldl $OS_LIBS"
-else
-  echo "$ac_t""no" 1>&6
-fi
-
-
-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"
@@ -3911,16 +4766,73 @@ fi
 
 
 
 
 
 
 
 
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+MAKEFILES="
+Makefile 
+config/Makefile
+config/autoconf.mk
+config/nsprincl.mk
+config/nsprincl.sh
+lib/Makefile 
+lib/ds/Makefile 
+lib/libc/Makefile 
+lib/libc/include/Makefile 
+lib/libc/src/Makefile 
+pr/Makefile 
+pr/include/Makefile 
+pr/include/md/Makefile 
+pr/include/obsolete/Makefile 
+pr/include/private/Makefile 
+pr/src/Makefile 
+pr/src/io/Makefile 
+pr/src/linking/Makefile 
+pr/src/malloc/Makefile 
+pr/src/md/Makefile 
+pr/src/md/${PR_MD_ARCH_DIR}/Makefile 
+pr/src/memory/Makefile 
+pr/src/misc/Makefile 
+pr/src/threads/Makefile 
+pr/tests/Makefile 
+pr/tests/dll/Makefile 
+"
+
+
+if test -z "$USE_PTHREADS" && test -z "$USE_BTHREADS"; then
+    MAKEFILES="$MAKEFILES pr/src/threads/combined/Makefile"
+elif test -n "$USE_PTHREADS"; then
+    MAKEFILES="$MAKEFILES pr/src/pthreads/Makefile"
+elif test -n "$USE_BTHREADS"; then
+    MAKEFILES="$MAKEFILES pr/src/bthreads/Makefile"
+fi
+
+if test -n "$USE_CPLUS"; then
+    MAKEFILES="$MAKEFILES pr/src/cplus/Makefile pr/src/cplus/tests/Makefile"
+fi
+
 trap '' 1 2 15
 cat > confcache <<\EOF
 # This file is a shell script that caches the results of configure
 # tests run on this system so they can be shared between configure
 # scripts and configure runs.  It is not useful on other systems.
 # If it contains results you don't want to keep, you may remove or edit it.
 #
 # By default, configure uses ./config.cache as the cache file,
@@ -4022,62 +4934,18 @@ do
     exit 0 ;;
   -help | --help | --hel | --he | --h)
     echo "\$ac_cs_usage"; exit 0 ;;
   *) echo "\$ac_cs_usage"; exit 1 ;;
   esac
 done
 
 ac_given_srcdir=$srcdir
-ac_given_INSTALL="$INSTALL"
-
-trap 'rm -fr `echo "
-Makefile 
-config/Makefile
-config/autoconf.mk
-config/nsprincl.mk
-config/nsprincl.sh
-lib/Makefile 
-lib/ds/Makefile 
-lib/libc/Makefile 
-lib/libc/include/Makefile 
-lib/libc/src/Makefile 
-lib/msgc/Makefile 
-lib/msgc/include/Makefile 
-lib/msgc/src/Makefile 
-lib/msgc/tests/Makefile
-lib/prstreams/Makefile 
-lib/tests/Makefile 
-pr/Makefile 
-pr/include/Makefile 
-pr/include/md/Makefile 
-pr/include/obsolete/Makefile 
-pr/include/private/Makefile 
-pr/src/Makefile 
-pr/src/bthreads/Makefile 
-pr/src/cplus/Makefile 
-pr/src/cplus/tests/Makefile 
-pr/src/io/Makefile 
-pr/src/linking/Makefile 
-pr/src/malloc/Makefile 
-pr/src/md/Makefile 
-pr/src/md/beos/Makefile 
-pr/src/md/os2/Makefile 
-pr/src/md/unix/Makefile 
-pr/src/md/windows/Makefile 
-pr/src/memory/Makefile 
-pr/src/misc/Makefile 
-pr/src/pthreads/Makefile 
-pr/src/threads/Makefile 
-pr/src/threads/combined/Makefile 
-pr/tests/Makefile 
-pr/tests/dll/Makefile 
-pr/tests/w16gui/Makefile 
-tools/Makefile 
-" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
+
+trap 'rm -fr `echo "$MAKEFILES" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
 EOF
 cat >> $CONFIG_STATUS <<EOF
 
 # Protect against being on the right side of a sed subst in config.status.
 sed 's/%@/@@/; s/@%/@@/; s/%g\$/@g/; /@g\$/s/[\\\\&%]/\\\\&/g;
  s/@@/%@/; s/@@/@%/; s/@g\$/%g/' > conftest.subs <<\\CEOF
 $ac_vpsub
 $extrasub
@@ -4122,43 +4990,44 @@ s%@build_os@%$build_os%g
 s%@WHOAMI@%$WHOAMI%g
 s%@HOST_CC@%$HOST_CC%g
 s%@CC@%$CC%g
 s%@CXX@%$CXX%g
 s%@RANLIB@%$RANLIB%g
 s%@AR@%$AR%g
 s%@AS@%$AS%g
 s%@LD@%$LD%g
+s%@STRIP@%$STRIP%g
 s%@DLLTOOL@%$DLLTOOL%g
 s%@WINDRES@%$WINDRES%g
-s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g
-s%@INSTALL_SCRIPT@%$INSTALL_SCRIPT%g
-s%@INSTALL_DATA@%$INSTALL_DATA%g
-s%@LN_S@%$LN_S%g
 s%@PERL@%$PERL%g
 s%@CPP@%$CPP%g
 s%@MOZILLA_CLIENT@%$MOZILLA_CLIENT%g
 s%@HOST_CFLAGS@%$HOST_CFLAGS%g
 s%@GNU_CC@%$GNU_CC%g
+s%@CROSS_COMPILE@%$CROSS_COMPILE%g
+s%@MOZ_OPTIMIZE@%$MOZ_OPTIMIZE%g
 s%@USE_CPLUS@%$USE_CPLUS%g
 s%@USE_IPV6@%$USE_IPV6%g
 s%@USE_N32@%$USE_N32%g
 s%@USE_64@%$USE_64%g
+s%@GC_LEAK_DETECTOR@%$GC_LEAK_DETECTOR%g
 s%@USE_PTHREADS@%$USE_PTHREADS%g
 s%@USE_BTHREADS@%$USE_BTHREADS%g
 s%@USE_USER_PTHREADS@%$USE_USER_PTHREADS%g
 s%@USE_NATIVE_THREADS@%$USE_NATIVE_THREADS%g
 s%@USE_NSPR_THREADS@%$USE_NSPR_THREADS%g
 s%@NSPR_VERSION@%$NSPR_VERSION%g
 s%@NSPR_MODNAME@%$NSPR_MODNAME%g
 s%@MDCPUCFG_H@%$MDCPUCFG_H%g
-s%@MOZ_TARGET@%$MOZ_TARGET%g
+s%@MOZ_WIN32_TARGET@%$MOZ_WIN32_TARGET%g
 s%@PR_MD_CSRCS@%$PR_MD_CSRCS%g
 s%@PR_MD_ASFILES@%$PR_MD_ASFILES%g
 s%@PR_MD_ARCH_DIR@%$PR_MD_ARCH_DIR%g
+s%@CPU_ARCH@%$CPU_ARCH%g
 s%@OBJ_SUFFIX@%$OBJ_SUFFIX%g
 s%@LIB_SUFFIX@%$LIB_SUFFIX%g
 s%@DLL_SUFFIX@%$DLL_SUFFIX%g
 s%@MKSHLIB@%$MKSHLIB%g
 s%@DSO_CFLAGS@%$DSO_CFLAGS%g
 s%@DSO_LDOPTS@%$DSO_LDOPTS%g
 s%@OS_TARGET@%$OS_TARGET%g
 s%@OS_ARCH@%$OS_ARCH%g
@@ -4169,16 +5038,24 @@ s%@AR_FLAGS@%$AR_FLAGS%g
 s%@ASFLAGS@%$ASFLAGS%g
 s%@OS_LIBS@%$OS_LIBS%g
 s%@RESOLVE_LINK_SYMBOLS@%$RESOLVE_LINK_SYMBOLS%g
 s%@AIX_LINK_OPTS@%$AIX_LINK_OPTS%g
 s%@NOSUCHFILE@%$NOSUCHFILE%g
 s%@MOZ_OBJFORMAT@%$MOZ_OBJFORMAT%g
 s%@ULTRASPARC_LIBRARY@%$ULTRASPARC_LIBRARY%g
 s%@ULTRASPARC_FILTER_LIBRARY@%$ULTRASPARC_FILTER_LIBRARY%g
+s%@OBJDIR@%$OBJDIR%g
+s%@OBJDIR_NAME@%$OBJDIR_NAME%g
+s%@NSINSTALL@%$NSINSTALL%g
+s%@OPTIMIZER@%$OPTIMIZER%g
+s%@RC@%$RC%g
+s%@CPU_ARCH_TAG@%$CPU_ARCH_TAG%g
+s%@DLLFLAGS@%$DLLFLAGS%g
+s%@OS_DLLFLAGS@%$OS_DLLFLAGS%g
 
 CEOF
 EOF
 
 cat >> $CONFIG_STATUS <<\EOF
 
 # Split the substitutions into bite-sized pieces for seds with
 # small command number limits, like on Digital OSF/1 and HP-UX.
@@ -4210,59 +5087,17 @@ while $ac_more_lines; do
 done
 if test -z "$ac_sed_cmds"; then
   ac_sed_cmds=cat
 fi
 EOF
 
 cat >> $CONFIG_STATUS <<EOF
 
-CONFIG_FILES=\${CONFIG_FILES-"Makefile 
-config/Makefile
-config/autoconf.mk
-config/nsprincl.mk
-config/nsprincl.sh
-lib/Makefile 
-lib/ds/Makefile 
-lib/libc/Makefile 
-lib/libc/include/Makefile 
-lib/libc/src/Makefile 
-lib/msgc/Makefile 
-lib/msgc/include/Makefile 
-lib/msgc/src/Makefile 
-lib/msgc/tests/Makefile
-lib/prstreams/Makefile 
-lib/tests/Makefile 
-pr/Makefile 
-pr/include/Makefile 
-pr/include/md/Makefile 
-pr/include/obsolete/Makefile 
-pr/include/private/Makefile 
-pr/src/Makefile 
-pr/src/bthreads/Makefile 
-pr/src/cplus/Makefile 
-pr/src/cplus/tests/Makefile 
-pr/src/io/Makefile 
-pr/src/linking/Makefile 
-pr/src/malloc/Makefile 
-pr/src/md/Makefile 
-pr/src/md/beos/Makefile 
-pr/src/md/os2/Makefile 
-pr/src/md/unix/Makefile 
-pr/src/md/windows/Makefile 
-pr/src/memory/Makefile 
-pr/src/misc/Makefile 
-pr/src/pthreads/Makefile 
-pr/src/threads/Makefile 
-pr/src/threads/combined/Makefile 
-pr/tests/Makefile 
-pr/tests/dll/Makefile 
-pr/tests/w16gui/Makefile 
-tools/Makefile 
-"}
+CONFIG_FILES=\${CONFIG_FILES-"$MAKEFILES"}
 EOF
 cat >> $CONFIG_STATUS <<\EOF
 for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then
   # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
   case "$ac_file" in
   *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'`
        ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
   *) ac_file_in="${ac_file}.in" ;;
@@ -4287,45 +5122,39 @@ for ac_file in .. $CONFIG_FILES; do if t
       if test -z "$ac_dots"; then top_srcdir=.
       else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;;
   /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;;
   *) # Relative path.
     srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix"
     top_srcdir="$ac_dots$ac_given_srcdir" ;;
   esac
 
-  case "$ac_given_INSTALL" in
-  [/$]*) INSTALL="$ac_given_INSTALL" ;;
-  *) INSTALL="$ac_dots$ac_given_INSTALL" ;;
-  esac
 
   echo creating "$ac_file"
   rm -f "$ac_file"
   configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure."
   case "$ac_file" in
   *Makefile*) ac_comsub="1i\\
 # $configure_input" ;;
   *) ac_comsub= ;;
   esac
 
   ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"`
   sed -e "$ac_comsub
 s%@configure_input@%$configure_input%g
 s%@srcdir@%$srcdir%g
 s%@top_srcdir@%$top_srcdir%g
-s%@INSTALL@%$INSTALL%g
 " $ac_file_inputs | (eval "$ac_sed_cmds") > $ac_file
 fi; done
 rm -f conftest.s*
 
 EOF
 cat >> $CONFIG_STATUS <<EOF
 
 EOF
 cat >> $CONFIG_STATUS <<\EOF
 
 exit 0
 EOF
 chmod +x $CONFIG_STATUS
 rm -fr confdefs* $ac_clean_files
 test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1
 
-
--- a/configure.in
+++ b/configure.in
@@ -18,25 +18,18 @@ dnl Rights Reserved.
 dnl
 dnl Contributor(s):
 dnl
 dnl Process this file with autoconf to produce a configure script.
 dnl
 AC_PREREQ(2.12)
 AC_INIT(config/libc_r.h)
 
-d=`pwd`
-if test "${srcdir}" = "$d" || test "${srcdir}" = "."  ; then
-   echo "Do not build in the srcdir as it will override Makefiles used by non-autoconf build."
-   exit 1;
-fi
-
 AC_CONFIG_AUX_DIR(${srcdir}/build/autoconf)
 AC_CANONICAL_SYSTEM
-AC_VALIDATE_CACHED_SYSTEM_TUPLE
 AC_PREFIX_DEFAULT(\${MOD_DEPTH}/dist)
 
 dnl Set this define to make fixes w/o breaking anything else.
 AC_DEFINE(USE_AUTOCONF)
 
 dnl ========================================================
 dnl = Defaults
 dnl ========================================================
@@ -50,16 +43,21 @@ USE_N32=
 USE_64=
 USE_CPLUS=
 USE_IPV6=
 USE_MDUPDATE=
 _OPTIMIZE_FLAGS=-O
 _DEBUG_FLAGS=-g
 MOZ_DEBUG=1
 MOZ_OPTIMIZE=
+OBJDIR=.
+OBJDIR_NAME=.
+NSINSTALL='$(MOD_DEPTH)/config/$(OBJDIR_NAME)/nsinstall'
+NOSUCHFILE=/no-such-file
+
 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
@@ -67,16 +65,47 @@ dnl =
 dnl ========================================================
 CFLAGS="${CFLAGS=}"
 CXXFLAGS="${CXXFLAGS=}"
 LDFLAGS="${LDFLAGS=}"
 HOST_CFLAGS="${HOST_CFLAGS=}"
 HOST_LDFLAGS="${HOST_LDFLAGS=}"
 
 dnl ========================================================
+dnl = Irix 6.x should use n32 ABI by default
+dnl ========================================================
+case "$target" in
+*-irix6*)
+	USE_N32=1 ;;
+*-cygwin*)
+    # Check to see if we are really running in a msvc environemnt
+    _WIN32_MSVC=
+    if test "$CC" = "cl" || test "$CXX" = "cl"; then
+        _WIN32_MSVC=1
+    elif test -z "$CC"; then
+        echo 'main() { return 0; }' > dummy.c
+        cl -o dummy dummy.c
+        if test $? = 0; then
+            _WIN32_MSVC=1
+        fi
+        rm -f dummy dummy.o dummy.obj dummy.exe dummy.c
+    fi
+    ;;
+*-msvc*)
+    _WIN32_MSVC=1
+    ;;
+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 ========================================================
 dnl Check if NSPR is being compiled for Mozilla
 dnl Let --with-arg override environment setting
 dnl
 AC_ARG_WITH(mozilla,
@@ -87,61 +116,77 @@ AC_ARG_WITH(mozilla,
 	    else
 	        MOZILLA_CLIENT=
 	    fi],
     [	if test -n "$MOZILLA_CLIENT"; then
 	        AC_DEFINE(MOZILLA_CLIENT)
 	    fi])
 
 AC_ARG_ENABLE(optimize,
-    [  --enable-optimize       Enable code optimizations],
-    MOZ_OPTIMIZE=1)
+    [  --enable-optimize(=flag) Enable code optimizations (flag, 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
+    fi ])
 
 AC_ARG_ENABLE(debug,
     [  --disable-debug         Do not compile in debugging symbols],
     [	if test "$enableval" = "no"; then
     	    MOZ_DEBUG=
 	    fi])
 
 AC_ARG_ENABLE(shared,
     [  --disable-shared        Do not compile into shared libraries])
 
-AC_ARG_ENABLE(target,
-    [  --enable-target=\$t      Turn on features for target \$t when build has multiple targets],
-    MOZ_TARGET=`echo $enableval | tr a-z A-Z`,
-    MOZ_TARGET=)
+AC_ARG_ENABLE(win32-target,
+    [  --enable-win32-target=\$t
+                               Specify win32 flavor. (WIN95 or WINNT)],
+    MOZ_WIN32_TARGET=`echo $enableval | tr a-z A-Z`,
+    MOZ_WIN32_TARGET=)
 
 AC_ARG_ENABLE(n32,
-    [  --enable-n32            Enable n32 support (IRIX only)],
+    [  --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
       fi ])
 
 AC_ARG_ENABLE(mdupdate,
     [  --enable-mdupdate       Enable use of certain compilers' mdupdate feature],
     [ if test "$enableval" = "yes"; then
 	    USE_MDUPDATE=1
       fi ])
 
-AC_PATH_PROG(WHOAMI, whoami, :)
+if test -z "$SKIP_PATH_CHECKS"; then
+    AC_PATH_PROG(WHOAMI, $WHOAMI whoami, echo not_whoami)
+elif test -z "$WHOAMI"; then
+    WHOAMI=whoami
+fi
+
 if test -n "$MOZ_DEBUG"; then
     AC_DEFINE(DEBUG)
     AC_DEFINE_UNQUOTED(DEBUG_`$WHOAMI`)
     DEFINES="$DEFINES -UNDEBUG"
 else
     AC_DEFINE(NDEBUG)
-    DEFINES="$DEFINES -UDEBUG"    
+    DEFINES="$DEFINES -U_DEBUG -UDEBUG"
 fi
 
+if test -z "$SKIP_COMPILER_CHECKS"; then
 dnl ========================================================
 dnl Checks for compilers.
 dnl ========================================================
 if test "$target" != "$host"; then
     echo "cross compiling from $host to $target"
     cross_compiling=yes
 
     _SAVE_CC="$CC"
@@ -172,97 +217,244 @@ if test "$target" != "$host"; then
 	[ac_cv_prog_host_cc_works=1 AC_MSG_RESULT([yes])],
 	AC_MSG_ERROR([installation or configuration problem: $host compiler $HOST_CC cannot create executables.]) )
     
     CC=$_SAVE_CC
     CFLAGS=$_SAVE_CFLAGS
     LDFLAGS=$_SAVE_LDFLAGS
 
     if test -z "$CC"; then
-	    AC_CHECK_PROGS(CC, "${target_alias}-gcc" "${target}-gcc", :)
+	    AC_CHECK_PROGS(CC, "${target_alias}-gcc" "${target}-gcc", echo)
     fi
     unset ac_cv_prog_CC
     AC_PROG_CC
     if test -z "$CXX"; then
-	    AC_CHECK_PROGS(CXX, "${target_alias}-g++" "${target}-g++", :)
+	    AC_CHECK_PROGS(CXX, "${target_alias}-g++" "${target}-g++", echo)
     fi
     unset ac_cv_prog_CXX
     AC_PROG_CXX
     if test -z "$RANLIB"; then
-	    AC_CHECK_PROGS(RANLIB, "${target_alias}-ranlib" "${target}-ranlib", :)
+	    AC_CHECK_PROGS(RANLIB, "${target_alias}-ranlib" "${target}-ranlib", echo)
     fi
     if test -z "$AR"; then
-	    AC_CHECK_PROGS(AR, "${target_alias}-ar" "${target}-ar", :)
+	    AC_CHECK_PROGS(AR, "${target_alias}-ar" "${target}-ar", echo)
     fi
     if test -z "$AS"; then
-	    AC_CHECK_PROGS(AS, "${target_alias}-as" "${target}-as", :)
+	    AC_CHECK_PROGS(AS, "${target_alias}-as" "${target}-as", echo)
     fi
     if test -z "$LD"; then
-	    AC_CHECK_PROGS(LD, "${target_alias}-ld" "${target}-ld", :)
+	    AC_CHECK_PROGS(LD, "${target_alias}-ld" "${target}-ld", echo)
+    fi
+    if test -z "$STRIP"; then
+	    AC_CHECK_PROGS(STRIP, "${target_alias}-strip" "${target}-strip", echo)
     fi
     if test -z "$DLLTOOL"; then
-	    AC_CHECK_PROGS(DLLTOOL, "${target_alias}-dlltool" "${target}-dlltool", :)
+	    AC_CHECK_PROGS(DLLTOOL, "${target_alias}-dlltool" "${target}-dlltool", echo)
     fi
     if test -z "$WINDRES"; then
-	    AC_CHECK_PROGS(WINDRES, "${target_alias}-windres" "${target}-windres", :)
+	    AC_CHECK_PROGS(WINDRES, "${target_alias}-windres" "${target}-windres", echo)
     fi
+
 else
-    AC_PROG_CC
     AC_PROG_CXX
+    if test "$CXX" = "cl" -a -z "$CC"; then
+        CC=$CXX
+    else        
+        AC_PROG_CC
+    fi
     AC_PROG_RANLIB
     AC_PATH_PROGS(AS, as, $CC)
-    AC_PATH_PROGS(AR, ar, :)
-    AC_PATH_PROGS(LD, ld, :)
-    AC_PATH_PROGS(DLLTOOL, dlltool, :)
-    AC_PATH_PROGS(WINDRES, windres, :)
+    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(DLLTOOL, dlltool, echo not_dlltool)
+    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
 fi
 
 if test "$GCC" = "yes"; then
     GNU_CC=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
+
+fi # SKIP_COMPILER_CHECKS
+
 dnl ========================================================
 dnl Checks for programs.
 dnl ========================================================
-AC_PROG_INSTALL
-AC_PROG_LN_S
-AC_PATH_PROGS(PERL, perl5 perl, :)
+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
 DLL_SUFFIX=so
 MKSHLIB='$(LD) $(DSO_LDOPTS) -o $@'
 PR_MD_ASFILES=
 PR_MD_CSRCS=
 PR_MD_ARCH_DIR=unix
 AR_FLAGS='cr $@'
+AS='$(CC)'
 
-OS_TARGET=`uname -s`
 OS_ARCH=`uname -s | sed -e 's|/|_|g'`
 OS_RELEASE=`uname -r`
 OS_TEST=`uname -m`
 
+if test "$OS_ARCH" = "IRIX64"; then
+    OS_ARCH=IRIX
+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.
+#
+if test "$OS_ARCH" = "WIN95"; then
+    OS_ARCH=WINNT
+    OS_TARGET=WIN95
+elif test "$OS_ARCH" = 'Windows_95'; then
+    OS_ARCH=Windows_NT
+    OS_TARGET=WIN95
+elif test "$OS_ARCH" = "CYGWIN_95-4.0"; then
+    OS_ARCH='CYGWIN_NT-4.0'
+    OS_TARGET=WIN95
+elif test "$OS_ARCH" = "OS2"; then
+    OS_ARCH=OS2
+    OS_TARGET=OS2
+fi
+
+#
+# On WIN32, we also define the variable CPU_ARCH.
+#
+
+if test "$OS_ARCH" = "WINNT"; then
+    CPU_ARCH=`uname -p`
+    if test "$CPU_ARCH" = "I386"; then
+        CPU_ARCH=x86
+    fi
+elif test "$OS_ARCH" = "Windows_NT"; then
+#
+# 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
+elif echo "$OS_ARCH" | grep -c CYGWIN_NT >/dev/null; then
+#
+# If uname -s returns "CYGWIN_NT-4.0", we assume that we are using
+# the uname.exe in the Cygwin tools.
+#
+    OS_RELEASE=`echo $OS_ARCH | sed 's|^CYGWIN_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
+elif test "$OS_ARCH" = "CYGWIN32_NT"; then
+#
+# 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.
+#
+    OS_ARCH=WINNT
+    CPU_ARCH=`uname -m`
+    #
+    # GNU-Win32's uname -m returns "i686" on a Pentium Pro machine.
+    #
+    if echo "$CPU_ARCH" | grep -c 86 >/dev/null; then
+        CPU_ARCH=x86
+    fi
+fi
+
+if test -n "$MOZILLA_CLIENT" && test "$OS_ARCH" = "WINNT"; then
+    OS_TARGET=WIN95
+    MOZ_WIN32_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
+if test -z "$MOZ_WIN32_TARGET"; then
+    MOZ_WIN32_TARGET=$OS_TARGET
+fi
+OS_CONFIG="${OS_TARGET}${OS_RELEASE}"
+
+dnl ========================================================
+
 dnl ========================================================
 dnl Override of system specific host options
 dnl ========================================================
 case "$host" in
-*-mingw*)
+*-mingw*|*-cygwin*|*-msvc*)
     ;;
 *-beos*)
     HOST_CFLAGS="$HOST_CFLAGS -DXP_BEOS -DBeOS -DBEOS -D_POSIX_SOURCE"
     ;;
 *)
     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
     ;;
 esac
@@ -272,16 +464,17 @@ dnl Override of system specific target o
 dnl ========================================================
 case "$target" in
 
 *-aix*)
     AC_DEFINE(XP_UNIX)
     AC_DEFINE(AIX)
     AC_DEFINE(SYSV)
     DSO_LDOPTS='-brtl -bM:SRE -bnoentry -bexpall'
+    OS_LIBS="-lc_r $OS_LIBS"
     case "${target_os}" in
     aix3.2*)
         USE_NSPR_THREADS=1
         AC_DEFINE(_PR_LOCAL_THREADS_ONLY)
         AC_DEFINE(AIX_RENAME_SELECT)
         AC_DEFINE(_PR_NO_LARGE_FILES)
         AIX_LINK_OPTS='-bnso -berok'
         PR_MD_ASFILES=os_AIX.s
@@ -289,105 +482,184 @@ case "$target" in
     aix4.1*)
         AC_DEFINE(AIX_RENAME_SELECT)
         AC_DEFINE(AIX_HAVE_ATOMIC_OP_H)
         AC_DEFINE(AIX_TIMERS)
         AC_DEFINE(_PR_NO_LARGE_FILES)
         AC_DEFINE(AIX4_1)
         MKSHLIB=
         DSO_LDOPTS=
+        USE_PTHREADS=1
         AIX_LINK_OPTS='-bnso -berok'
         ;;
     aix4.3*)
         AC_DEFINE(AIX_HAVE_ATOMIC_OP_H)
         AC_DEFINE(AIX_TIMERS)
         AC_DEFINE(_PR_HAVE_OFF64_T)
         AC_DEFINE(AIX4_3)
         AC_DEFINE(HAVE_SOCKLEN_T)
         USE_IPV6=1
+        USE_PTHREADS=1
         AIX_LINK_OPTS='-brtl -bnso -berok'
         ;;
     *)
         AC_DEFINE(AIX_HAVE_ATOMIC_OP_H)
         AC_DEFINE(AIX_TIMERS)
         AC_DEFINE(_PR_HAVE_OFF64_T)
         AIX_LINK_OPTS='-brtl -bnso -berok'
         ;;
     esac
     CFLAGS="$CFLAGS -qro -qroconst"
-    if test `grep -c xlC_r $CC`; then
+    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
         MDCPUCFG_H=_aix64.cfg
     else
         if test -n "$USE_IPV6"; then
             MDCPUCFG_H=_aix32in6.cfg
         else
             MDCPUCFG_H=_aix32.cfg
         fi
     fi
     PR_MD_CSRCS=aix.c
+    RESOLVE_LINK_SYMBOLS=1
     ;;
         
 *-beos*)
     AC_DEFINE(XP_BEOS)
     AC_DEFINE(BeOS)
     AC_DEFINE(BEOS)
     AC_DEFINE(_POSIX_SOURCE)
     DSO_LDOPTS=-nostart
-    MKSHLIB='$(CCC) $(DSO_LDOPTS) -o $@'
     MDCPUCFG_H=_beos.cfg
     USE_BTHREADS=1
     PR_MD_ARCH_DIR=beos
     RESOLVE_LINK_SYMBOLS=1
+    case "${target_cpu}" in
+    i?86)
+        _OPTIMIZE_FLAGS=-O2
+        _DEBUG_FLAGS='-gdwarf-2 -O0'
+        MKSHLIB='$(CCC) $(DSO_LDOPTS) -o $@'
+        ;;
+    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
+
+    MDCPUCFG_H=_bsdi.cfg
+    PR_MD_CSRCS=bsdi.c
+
+    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)
+        PR_MD_ASFILES=os_BSD_OS_386_2.s
+        ;;
+
+    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 -Wl,-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
+
     ;;
 
 *-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)
-    MKSHLIB='$(LD) $(DSO_LDOPTS)'
     DSO_LDOPTS=-G
-    NOSUCHFILE=/no-such-file
     _OPTIMIZE_FLAGS=-O2
     _DEBUG_FLAGS=
     MDCPUCFG_H=_dgux.cfg
     PR_MD_CSRCS=dgux.c
     ;;
 
 *-freebsd*)
-    if test "${target_cpu}" != "alpha"; then
-        AC_DEFINE(i386)
-    fi
     AC_DEFINE(FREEBSD)
     AC_DEFINE(HAVE_BSD_FLOCK)
     CFLAGS="$CFLAGS $(DSO_CFLAGS) -ansi -Wall -pipe"
     MOZ_OBJFORMAT=`test -x /usr/bin/objformat && /usr/bin/objformat || echo aout`
     if test "$MOZ_OBJFORMAT" = "elf"; then
         DLL_SUFFIX=so
     else
         DLL_SUFFIX=so.1.0
     fi
     DSO_CFLAGS=-fPIC
     DSO_LDOPTS=-Bshareable
     MDCPUCFG_H=_freebsd.cfg
     PR_MD_CSRCS=freebsd.c
     ;;
 
 *-hpux*)
+    AC_DEFINE(XP_UNIX)
     AC_DEFINE(HPUX)
     AC_DEFINE(_HPUX_SOURCE)
-    DEFINES="$DEFINES -D${target_cpu}"
+    AC_DEFINE(hppa)
     DLL_SUFFIX=sl
     DSO_LDOPTS='-b +h $(notdir $@)'
     PR_MD_CSRCS=hpux.c
     if test -n "$USE_64"; then
         MDCPUCFG_H=_hpux64.cfg
     else
         MDCPUCFG_H=_hpux32.cfg
     fi
@@ -395,133 +667,163 @@ case "$target" in
         CC="$CC -Ae"
         CXX="$CXX -ext"
         CFLAGS="$CFLAGS +ESlit"
         CXXFLAGS="$CXXFLAGS +ESlit"
         DSO_CFLAGS=+Z
     else
         DSO_CFLAGS=-fPIC
     fi
+
     if test -n "$MOZILLA_CLIENT"; then
-        USE_NSPR_THREADS=1
+        DEFAULT_IMPL_STRATEGY=_EMU
     fi
-    case "${target_os}" in
-    hpuxA.09*)
-        AC_DEFINE(HPUX9)
+
+    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)
-        ;;
-    hpuxB.10.01*)
+    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)' >/dev/null; then
+        AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
+    fi
+
+    if test "$OS_RELEASE" = "B.10.01"; then
         AC_DEFINE(HPUX10)
-        ;;
-    hpuxB.10.10*)
+        DEFAULT_IMPL_STRATEGY=_EMU
+    fi
+
+    if test "$OS_RELEASE" = "B.10.10"; then
         AC_DEFINE(HPUX10)
         AC_DEFINE(HPUX10_10)
-        AC_DEFINE(HAVE_INT_LOCALTIME_R)
-        USE_PTHREADS=1
-        USE_NSPR_THREADS=
-        ;;
-    hpuxB.10.20*)
+        DEFAULT_IMPL_STRATEGY=_PTH
+    fi
+
+    if test "$OS_RELEASE" = "B.10.20"; then
         AC_DEFINE(HPUX10)
         AC_DEFINE(HPUX10_20)
-        AC_DEFINE(HAVE_INT_LOCALTIME_R)
-        if test -z "$GNU_CC"; then
+        if test -z "$GNU_CC" && test 0 = 1; then
             CFLAGS="$CFLAGS +DAportable +DS1.1"
             CXXFLAGS="$CXXFLAGS +DAportable +DS1.1"
         fi
-        USE_PTHREADS=1
-        USE_NSPR_THREADS=
-        ;;
-    hpuxB.10.30*)
-        AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
-        if test -z "$GNU_CC"; then
+        DEFAULT_IMPL_STRATEGY=_EMU
+    fi
+
+    if test "$OS_RELEASE" = "B.10.30"; then
+        AC_DEFINE(HPUX10)
+        AC_DEFINE(HPUX10_30)
+        #CXX="/opt/aCC/bin/aCC -ext"
+        if test -z "$GNU_CC" && test 0 = 1; then
             CFLAGS="$CFLAGS +DAportable +DS1.1"
             CXXFLAGS="$CXXFLAGS +DAportable +DS1.1"
         fi
-        USE_PTHREADS=1
-        USE_NSPR_THREADS=
-        ;;
-    hpuxB.11.00*)
+        DEFAULT_IMPL_STRATEGY=_PTH
+    fi
+
+    if test "$OS_RELEASE" = "B.11.00"; then
         AC_DEFINE(HPUX10)
         AC_DEFINE(HPUX11)
         AC_DEFINE(_LARGEFILE64_SOURCE)
         AC_DEFINE(_PR_HAVE_OFF64_T)
         AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
         if test -z "$GNU_CC"; then
+            if test 0 = 1; 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
         fi
+        DEFAULT_IMPL_STRATEGY=_PTH
+    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
-        USE_NSPR_THREADS=
-        ;;
-    esac
-    case "${target_os}" in
-    hpuxB.10*)
-        AC_DEFINE(_PR_NO_LARGE_FILES)
-        ;;
-    esac
-    if test -n "$USE_NSPR_THREADS"; then
-        AC_DEFINE(_PR_LOCAL_THREADS_ONLY)
+        if test "$MOZILLA_CLIENT"; 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)
     PR_MD_CSRCS=irix.c
     PR_MD_ASFILES=os_Irix.s
-    MKSHLIB='$(LD) $(SHLIB_LD_OPTS) -rdata_shared -shared -soname $(notdir $@) -o $@'
-    DSO_LDOPTS='-elf -shared -all'
+    MKSHLIB='$(LD) $(DSO_LDOPTS) -rdata_shared -shared -soname $(notdir $@) -o $@'
+    #DSO_LDOPTS='-elf -shared -all'
     if test -n "$USE_64"; then
         MDCPUCFG_H=_irix64.cfg
     else
         MDCPUCFG_H=_irix32.cfg
     fi
     case "${target_os}" in
     irix5*)
 	   USE_NSPR_THREADS=1
 	   ;;
     *)
-	   USE_N32=1
 	   USE_PTHREADS=1
 	   ;;
  	esac
     if test "$GNU_CC"; then
 	    AS='$(CC) -x assembler-with-cpp -D_ASM -mips2 $(INCLUDES)'
 	    CFLAGS="$CFLAGS -Wall -Wno-format"
 	    _OPTIMIZE_FLAGS="-O6"
     else
-	    AS="as -D_ASM $(INCLUDES) -n32"
+	    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"
 	    fi
 	    case "$target}" in
 	    *-irix6.*)
 	        CFLAGS="$CFLAGS -multigot"
-	        SHLIB_LD_OPTS="-no_unresolved"
-	        if test "USE_N32"; then
+	        DSO_LDOPTS="-no_unresolved"
+	        if test "$USE_N32"; then
 		        CFLAGS="$CFLAGS -n32 -woff 1209"
 		        LDFLAGS="$LDFLAGS -n32"
-		        SHLIB_LD_OPTS="$SHLIB_LD_OPTS -n32"
+		        DSO_LDOPTS="$DSO_LDOPTS -n32"
 		        if test "${target_os}" = "irix6.2"; then
 		            LDFLAGS="$LDFLAGS -Wl,-woff,85"
-		            SHLIB_LD_OPTS="$SHLIB_LD_OPTS -woff 85"
+		            DSO_LDOPTS="$DSO_LDOPTS -woff 85"
 		        fi
 	        else
 		        if test "$USE_64"; then
 		            CFLAGS="$CFLAGS -64"
 		        else
 		            CFLAGS="$CFLAGS -32"
 		        fi
 	        fi
@@ -573,90 +875,408 @@ case "$target" in
     case "${target_cpu}" in
     alpha)
         AC_DEFINE(_ALPHA_)
         AC_DEFINE(__alpha)
         CFLAGS="$CFLAGS -mieee"
         CXXFLAGS="$CXXFLAGS -mieee"
         _OPTIMIZE_FLAGS=-O2
         ;;
+    i?86)
+        PR_MD_ASFILES=os_Linux_x86.s
+        _OPTIMIZE_FLAGS=-O2
+        ;;
     m68k)
         _OPTIMIZE_FLAGS=-O
         CFLAGS="$CFLAGS -m68020-40"
         CXXFLAGS="$CXXFLAGS -m68020-40"
         ;;
     *)
         _OPTIMIZE_FLAGS=-O2
         ;;
     esac    
     ;;
 
-*-mingw*)
+*-mingw*|*-cygwin*|*-msvc*)
     AC_DEFINE(XP_PC)
-    AC_DEFINE(NONAMELESSUNION)
+    AC_DEFINE(WIN32)
     PR_MD_ARCH_DIR=windows
-    if test -z "$GNU_CC"; then
+
+    if test -n "$GNU_CC"; then
+        AC_DEFINE(NONAMELESSUNION)
+        MKSHLIB='$(DLLTOOL) --as=$(AS) -k --dllname $*.dll --output-lib $@'
+    else
+        CC=cl
+        CXX=cl
+        LD=link
+        AR='lib -NOLOGO -OUT:"$@"'
+        AR_FLAGS=
+        RANLIB='echo not_ranlib'
+        STRIP='echo not_strip'
+        NSINSTALL=nsinstall
+        RC=rc.exe
+        GARBAGE='$(OBJDIR)/vc20.pdb $(OBJDIR)/vc40.pdb'
 	    OBJ_SUFFIX=obj
 	    LIB_SUFFIX=lib
 	    DLL_SUFFIX=dll
+        
+        CFLAGS="$CFLAGS -W3 -nologo -GF -Gy"
+        _DEBUG_FLAGS=
+
+        if test -n "$MOZ_OPTIMIZE"; then
+            CFLAGS="$CFLAGS -MD"
+            OPTIMIZER=-O2
+            DLLFLAGS='-OUT:"$@"'
+            OBJDIR_TAG=_OPT
+
+            if test -n "$MOZ_PROFILE"; then
+                OPTIMIZER="$OPTIMIZER -Z7"
+                DLLFLAGS="$DLLFLAGS -DEBUG -DEBUGTYPE:CV"
+                LDFLAGS="$LDFLAGS -DEBUG -DEBUGTYPE:CV"
     fi
-    MKSHLIB='$(DLLTOOL) --as=$(AS) -k --dllname $*.dll --output-lib $@'
+        else
+            if test -n "$USE_DEBUG_RTL"; then
+                CFLAGS="$CFLAGS -MDd"
+            else
+                CFLAGS="$CFLAGS -MD"
+            fi
+            OPTIMIZER="-Od -Z7"
+            DLLFLAGS='-DEBUG -DEBUGTYPE:CV -OUT:"$@"'
+            if test -n "$GLOWCODE"; then
+                DLLFLAGS='-DEBUG -DEBUGTYPE:both -INCLUDE:_GlowCode -OUT:"$@"'
+            fi
+            OBJDIR_TAG=_DBG
+            LDFLAGS="$LDFLAGS -DEBUG -DEBUGTYPE:CV"
+            if test -n "$PROFILE"; then
+                LDFLAGS="$LDFLAGS -PROFILE -MAP"
+                DLLFLAGS="$DLLFLAGS -PROFILE -MAP"
+            fi
+        fi
+    fi
 
-    case "$MOZ_TARGET" in
+    if test -n "$USE_STATIC_TLS"; then
+        AC_DEFINE(_PR_USE_STATIC_TLS)
+    fi
+
+    if test "$OS_TARGET" = "WINNT"; then
+        if test -z "$GNU_CC"; then
+            CFLAGS="$CFLAGS -GT"
+        fi
+        if test "$CPU_ARCH" = "x86"; then
+            CFLAGS="$CFLAGS -G5"
+        fi
+        AC_DEFINE(WINNT)
+    else
+        AC_DEFINE(WIN95)
+        AC_DEFINE(_PR_GLOBAL_THREADS_ONLY)
+    fi
+
+    if test "$CPU_ARCH" = "x86"; then
+        CPU_ARCH_TAG=
+    else
+        CPU_ARCH_TAG=$CPU_ARCH
+    fi
+
+    if test -n "$USE_DEBUG_RTL"; then
+        OBJDIR_SUFFIX=OBJD
+    else
+        OBJDIR_SUFFIX=OBJ
+    fi
+
+    OBJDIR_NAME="${OS_CONFIG}${CPU_ARCH_TAG}${OBJDIR_TAG}.${OBJDIR_SUFFIX}"
+    OBJDIR='${OBJDIR_NAME}'
+
+    OS_DLLFLAGS='-nologo -DLL -SUBSYSTEM:WINDOWS -PDB:NONE'
+
+    case "$MOZ_WIN32_TARGET" in
     WINNT)
-	    DEFINES="$DEFINES -DWIN32 -DWINNT -DWin32_Winsock"
 	    MDCPUCFG_H=_winnt.cfg
 	    ;;
     WIN95)
-	    DEFINES="$DEFINES -UWINNT -DWIN32 -DWIN95 -DWin32_Winsock -D_PR_GLOBAL_THREADS_ONLY"
 	    MDCPUCFG_H=_win95.cfg
 	    ;;
     WIN16)
-	    DEFINES="$DEFINES -UWINNT"
 	    MDCPUCFG_H=_win16.cfg
 	    ;;
     *)
-	    AC_MSG_ERROR([Missing MOZ_TARGET for ${target}.  Use --enable-target to set.])
+	    AC_MSG_ERROR([Missing MOZ_WIN32_TARGET for ${target}.  Use --enable-win32-target to set.])
    	;;
     esac
 
-    case "$target" in
-    i?86-*)
+    case "$target_cpu" in
+    i?86)
 	    AC_DEFINE(_X86_)
         ;;
-    alpha-*)
+    alpha)
 	    AC_DEFINE(_ALPHA_)
    	    ;;
-    mips-*)
+    mips)
 	    AC_DEFINE(_MIPS_)
 	    ;;
     *)
 	    AC_DEFINE(_CPU_ARCH_NOT_DEFINED)
 	    ;;
     esac
+
     ;;
 
+*-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 -pipe"
+        CXXFLAGS="$CXXFLAGS -fPIC -Wall -pipe"
+        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)
+    if test -z "$OBJECT_FMT"; then
+        if echo __ELF__ | ${CC-cc} -E - | grep -q __ELF__ 2>/dev/null; then
+            OBJECT_FMT=a.out;
+        else
+            OBJECT_FMT=ELF
+        fi
+    fi
+    if test "$OBJECT_FMT" = "ELF"; then
+        DLL_SUFFIX=so
+    else
+        DLL_SUFFIX=so.1.0
+    fi
+    CFLAGS="$CFLAGS -ansi -Wall -pipe"
+    CXXFLAGS="$CXXFLAGS -ansi -Wall -pipe"
+    DSO_CFLAGS='-fPIC -DPIC'
+    DSO_LDOPTS='-x -shared'
+    if test "$LIBRUNPATH"; then
+        DSO_LDOPTS="$DSO_LDOPTS -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 -pipe -traditional-cpp -posix"
+    CXXFLAGS="$CXXFLAGS -Wall -fno-common -pipe -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)
     MDCPUCFG_H=_nto.cfg
     PR_MD_CSRCS=nto.c
-    MKSHLIB='qcc -Vgcc_ntox86 -shared -Wl,-h$(@:$(OBJDIR)/%.so=%.so) -o $(@:$(OBJDIR)/%.so=%.so)'
-    CFLAGS="$CFLAGS -Wc,-Wall -Wc,-Wno-parentheses -DNTO -D_QNX_SOURCE -DHAVE_POINTER_LOCALTIME_R -shared"
-    OS_LIBS="-lsocket"
-    _OPTIMIZE_FLAGS="-O2"
-    _DEBUG_FLAGS="-O2 -gdwarf-2"
+    MKSHLIB='qcc -Vgcc_ntox86 -shared -Wl,-h$(@:$(OBJDIR)/%.so=%.so) -M -o $(@:$(OBJDIR)/%.so=%.so)'
+    CFLAGS="$CFLAGS -Wc,-Wall -Wc,-Wno-parentheses -shared"
+    OS_LIBS="$OS_LIBS -lsocket"
+    _OPTIMIZE_FLAGS="-O1"
+    _DEBUG_FLAGS="-O1 -gstabs"
     COMPILER_TAG="_qcc"
     CC="qcc -Vgcc_ntox86 -w"
-    CXX="QCC -Vgcc_ntox86 -w"
-    CPP="qcc -Vgcc_ntox86 -w"
+    CXX='$(CC)'
     LD="qcc -Vgcc_ntox86 -nostdlib"
-    AR="qcc -Vgcc_ntox86 -M -a "
-    AR_FLAGS="$@"
+    AR="qcc -Vgcc_ntox86 -M -a $@"
+    AR_FLAGS=
 	;;
 
+*-openbsd*)
+    AC_DEFINE(XP_UNIX)
+    AC_DEFINE(OPENBSD)
+    AC_DEFINE(HAVE_BSD_FLOCK)
+    CFLAGS="$CFLAGS -ansi -Wall -pipe"
+    CXXFLAGS="$CXXFLAGS -ansi -Wall -pipe"
+    DLL_SUFFIX=so.1.0
+    DSO_CFLAGS=-fPIC
+    case "$OS_TEST" in
+    alpha|mips|pmax)
+        DSO_LDOPTS=-shared ;;
+    *)
+        DSO_LDOPTS=-Bshareable ;;
+    esac
+    ;;
+
+*-openvms*)
+    AC_DEFINE(XP_UNIX)
+    AC_DEFINE(VMS)
+    AC_DEFINE(VMS_AS_IS)
+    AC_DEFINE(GENERIC_PTHREAD_REDEFINES)
+    CROSS_COMPILE=1
+    HOST_CC=c89
+    HOST_CXX=cxx
+    HOST_CFLAGS=-O
+    HOST_CXXFLAGS=-O
+    CFLAGS="$CFLAGS -Wc,names=\(short,as\)"
+    CXXFLAGS="$CXXFLAGS -Wc,names=\(short,as\)"
+    MKSHLIB='vmsld $(OPTIMIZER)'
+    ;;
+
+*-osf1*)
+    AC_DEFINE(XP_UNIX)
+    AC_DEFINE(OSF1)
+
+    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='-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_POINTER_LOCALTIME_R)
+        AC_DEFINE(OSF1_HAVE_MACHINE_BUILTINS_H)
+    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
+    ;;
+
+*-rhapsody*)
+    AC_DEFINE(XP_UNIX)
+    AC_DEFINE(RHAPSODY)
+    AC_DEFINE(HAVE_BSD_FLOCK)
+    CFLAGS="$CFLAGS -Wmost -fno-common -pipe"    
+    if echo $OS_TEST | grep -c 86 2>/dev/null; then
+        CFLAGS="$CFLAGS -mno-486"
+        AC_DEFINE(i386)
+        CPU_ARCH=i386
+    else
+        AC_DEFINE(ppc)
+        CPU_ARCH=ppc
+    fi
+    DSO_LDOPTS='-dynamiclib -compatibility_version 1 -current_version 1 -all_load'
+    MKSHLIB='$(CC) -arch $(CPU_ARCH) $(DSO_LDOPTS) -o $@'
+    DLL_SUFFIX=dylib
+    USE_PTHREADS=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
+            CFLAGS="$CFLAGS -pipe"
+        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
+    ;;
+
 *-solaris*)
     AC_DEFINE(XP_UNIX)
     AC_DEFINE(SVR4)
     AC_DEFINE(SYSV)
     AC_DEFINE(__svr4)
     AC_DEFINE(__svr4__)
     AC_DEFINE(SOLARIS)
     if test -n "$USE_64"; then
@@ -670,35 +1290,34 @@ case "$target" in
         DSO_CFLAGS=-fPIC
     else
         DSO_CFLAGS=-KPIC
     fi
     AS='$(CC)'
     if test -z "$GNU_AS"; then
         ASFLAGS="$ASFLAGS -Wa,-P"
     fi
-    NOSUCHFILE=/no-such-file
     if test -n "$GNU_CC"; then
         if test -n "$USE_MDUPDATE"; then
-            CFLAGS="$CFLAGS -MDupdate"
-            CXXFLAGS="$CXXFLAGS -MDupdate"
+            CFLAGS="$CFLAGS -MDupdate \$(DEPENDENCIES)"
+            CXXFLAGS="$CXXFLAGS -MDupdate \$(DEPENDENCIES)"
         fi
     else
         CC="$CC -xstrconst"
         CXX="$CXX -Qoption cg -xstrconst"
     fi
     if test -n "$BUILD_NUMBER" && test -z "$MOZ_OPTIMIZE"; then
         CFLAGS="$CFLAGS -xs"
         CXXFLAGS="$CXXFLAGS -xs"
     fi
     if test -n "$USE_64" && test -z "$GNU_CC"; then
         CC="$CC -xarch=v9"
         CXX="$CXX -xarch=v9"
     fi
-    if test "${target_cpu}" = "i386"; then
+    if test "$OS_TEST" = "i86pc"; then
         AC_DEFINE(i386)
         if test -n "$MOZ_DEBUG" && test -n "$GNU_CC"; then
             _DEBUG_FLAGS="$_DEBUG_FLAGS -gstabs"
             if test -z "$GNU_AS"; then
                 _DEBUG_FLAGS="$_DEBUG_FLAGS -Wa,-s"
             fi
         fi
     fi
@@ -714,34 +1333,54 @@ case "$target" in
         ;;
     *)
         AC_DEFINE(_PR_HAVE_OFF64_T)
         if test -n "$GNU_CC"; then
             AC_DEFINE(_LARGEFILE64_SOURCE)
         fi
         ;;
     esac
-    if test "${target_cpu}" = "sun4u"; then
+    if test "$OS_TEST" = "sun4u"; then
         ULTRASPARC_LIBRARY=ultrasparc
         ULTRASPARC_FILTER_LIBRARY=libatomic.so
         DSO_LDOPTS="$DSO_LDOPTS -f "'$(ULTRASPARC_FILTER_LIBRARY)'
     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
 
 dnl Turn off shared libraries if asked to do so.
 if test "$enable_shared" = no; then
     MKSHLIB=
 fi
 
+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)
@@ -759,16 +1398,20 @@ 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)
 
@@ -801,25 +1444,61 @@ 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 ========================================================
 
-AC_CHECK_LIB(pthread, pthread_attr_init, 
-             _HAVE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthread",
-    AC_CHECK_LIB(c_r, pthread_attr_init,
-        _HAVE_PTHREADS=1 _PTHREAD_LDFLAGS="-lc_r",
-        AC_CHECK_LIB(c, pthread_attr_init,
-            _HAVE_PTHREADS=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
@@ -872,28 +1551,38 @@ case "$target" in
     [ 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          Use cplus for whatever reason],
     [ 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])
 
+
+AC_ARG_ENABLE(boehm,
+    [  --enable-boehm          Enable the Boehm Garbage Collector],
+    [ if test "$enableval" = "yes"; then
+        AC_DEFINE(GC_LEAK_DETECTOR)
+        GC_LEAK_DETECTOR=1
+    fi])
+
 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
@@ -901,109 +1590,140 @@ if test -n "$USE_PTHREADS"; 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
-    *-mingw*|*-cygwin*|*-uwin*)
+    *-mingw*|*-cygwin*|*-uwin*|*-msvc*)
 	    ;;
     *-solaris*)
 	    AC_DEFINE(_REENTRANT)
+        if test "$ac_cv_have_dash_pthreads" = "yes"; then
+            _PTHREAD_LDFLAGS=
+        fi
 	    ;;
-    *-freebsd*)
+    *-freebsd*|*-openbsd*|*-bsdi*|*-netbsd*)
 	    AC_DEFINE(_REENTRANT)
 	    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=
+	        _PTHREAD_LDFLAGS=
 	    fi
 	    ;;
-    *-hpuxB.10.10*)
-        AC_DEFINE(_REENTRANT)
-        AC_DEFINE(_PR_DCETHREADS)
-        ;;
-    *-hpuxB.10.20*)
-        AC_DEFINE(_REENTRANT)
-        AC_DEFINE(_PR_DCETHREADS)
-        ;;
-    *-hpux*)
-        AC_DEFINE(_POSIX_C_SOURCE=199506L)
-        ;;
     *)
 	    AC_DEFINE(_REENTRANT)
 	    ;;
     esac
 
-    AC_CHECK_FUNC(pthread_create,,[
-       AC_CHECK_LIB(pthread, pthread_create, [OS_LIBS="-lpthread $OS_LIBS"])
-    ])
-
 else 
     if test -n "$USE_USER_PTHREADS"; then
 	    USE_PTHREADS=
 	    USE_NSPR_THREADS=
     else
-	    USE_NSPR_THREADS=1
-	    dnl AC_DEFINE(_PR_LOCAL_THREADS_ONLY)
+        _PTHREAD_LDFLAGS=
+        if test -n "$USE_NSPR_THREADS"; then
+    	    AC_DEFINE(_PR_LOCAL_THREADS_ONLY)
+        fi
     fi
 fi
 dnl Special thread exceptions
 
 case "$target" in
 *-aix4.1*)
     if test -z "$USE_PTHREADS"; then
         AC_DEFINE(AIX_RENAME_SELECT)
     fi
     ;;
 *-aix4.[23]*)
     if test -z "$USE_NSPR_THREADS"; then
         AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
     fi
     ;;
-*-hpux*)
-    if test -n "$USE_USER_PTHREADS"; then
-        AC_DEFINE(_POSIX_C_SOURCE=199506L)
+*-bsdi*)
+    if test -n "$USE_PTHREADS"; then
+        AC_DEFINE(_PR_NEED_PTHREAD_INIT)
     fi
     ;;
-*-mingw*|*-cygwin*|*-uwin*)
+*-hpux*)
+    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)
+        fi
+    fi
+    if test "$USE_USER_PTHREADS"; then
+        AC_DEFINE_UNQUOTED(_POSIX_C_SOURCE,199506L)
+    fi
+    ;;
+*-mingw*|*-cygwin*|*-uwin*|*-msvc*)
     dnl win32 does not use pthreads
     USE_PTHREADS=
-    PTHREAD_LDFLAGS=
+    _PTHREAD_LDFLAGS=
     USE_USER_PTHREADS=
     ;;
+*-netbsd*)
+    if test -z "$USE_PTHREADS"; then
+        OS_LIBS="$OS_LIBS -lc"
+    fi
+    ;;    
 *-solaris*)
     if test -n "$USE_NATIVE_THREADS"; then
         AC_DEFINE(_PR_GLOBAL_THREADS_ONLY)
     else
         if test -n "$USE_USER_PTHREADS"; then
             AC_DEFINE(_PR_LOCAL_THREADS_ONLY)
         fi
     fi
     if test -z "$USE_USER_PTHREADS"; then
         AC_DEFINE(_REENTRANT)
         AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
-        if test "${target_cpu}" = "i386"; then
+        if test "$OS_TEST" = "i86pc"; then
             PR_MD_ASFILES=os_SunOS_x86.s
         else
             PR_MD_ASFILES=os_SunOS.s
             if test -z "$USE_64"; then
                 PR_MD_ASFILES="$PR_MD_ASFILES os_SunOS_32.s"
             fi
         fi
     fi
     ;;
 esac
 
-AC_CHECK_FUNC(dlopen,,[
-    AC_CHECK_LIB(dl, dlopen, [OS_LIBS="-ldl $OS_LIBS"])
-])
+OS_LIBS="$_PTHREAD_LDFLAGS $OS_LIBS"
+
+dnl If the user passed in arg to --enable-optimize,
+dnl make sure that we use it.
+if test -n "$_SAVE_OPTIMIZE_FLAGS"; then
+    _OPTIMIZE_FLAGS="$_SAVE_OPTIMIZE_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"
@@ -1017,35 +1737,40 @@ AC_SUBST(MOZILLA_CLIENT)
 AC_SUBST(CC)
 AC_SUBST(CXX)
 AC_SUBST(CFLAGS)
 AC_SUBST(CXXFLAGS)
 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(GC_LEAK_DETECTOR)
 
 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(NSPR_VERSION)
 AC_SUBST(NSPR_MODNAME)
 AC_SUBST(MDCPUCFG_H)
-AC_SUBST(MOZ_TARGET)
+AC_SUBST(MOZ_WIN32_TARGET)
 AC_SUBST(PR_MD_CSRCS)
 AC_SUBST(PR_MD_ASFILES)
 AC_SUBST(PR_MD_ARCH_DIR)
+AC_SUBST(CPU_ARCH)
 
 AC_SUBST(OBJ_SUFFIX)
 AC_SUBST(LIB_SUFFIX)
 AC_SUBST(DLL_SUFFIX)
 AC_SUBST(MKSHLIB)
 AC_SUBST(DSO_CFLAGS)
 AC_SUBST(DSO_LDOPTS)
 
@@ -1060,67 +1785,76 @@ AC_SUBST(AR)
 AC_SUBST(AR_FLAGS)
 AC_SUBST(AS)
 AC_SUBST(ASFLAGS)
 AC_SUBST(LD)
 AC_SUBST(DLLTOOL)
 AC_SUBST(WINDRES)
 AC_SUBST(RANLIB)
 AC_SUBST(PERL)
+AC_SUBST(STRIP)
 
 AC_SUBST(OS_LIBS)
 AC_SUBST(RESOLVE_LINK_SYMBOLS)
 AC_SUBST(AIX_LINK_OPTS)
 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(CPU_ARCH_TAG)
+AC_SUBST(DLLFLAGS)
+AC_SUBST(OS_DLLFLAGS)
+
 dnl ========================================================
 dnl Generate output files.
 dnl ========================================================
-AC_OUTPUT([
+MAKEFILES="
 Makefile 
 config/Makefile
 config/autoconf.mk
 config/nsprincl.mk
 config/nsprincl.sh
 lib/Makefile 
 lib/ds/Makefile 
 lib/libc/Makefile 
 lib/libc/include/Makefile 
 lib/libc/src/Makefile 
-lib/msgc/Makefile 
-lib/msgc/include/Makefile 
-lib/msgc/src/Makefile 
-lib/msgc/tests/Makefile
-lib/prstreams/Makefile 
-lib/tests/Makefile 
 pr/Makefile 
 pr/include/Makefile 
 pr/include/md/Makefile 
 pr/include/obsolete/Makefile 
 pr/include/private/Makefile 
 pr/src/Makefile 
-pr/src/bthreads/Makefile 
-pr/src/cplus/Makefile 
-pr/src/cplus/tests/Makefile 
 pr/src/io/Makefile 
 pr/src/linking/Makefile 
 pr/src/malloc/Makefile 
 pr/src/md/Makefile 
-pr/src/md/beos/Makefile 
-pr/src/md/os2/Makefile 
-pr/src/md/unix/Makefile 
-pr/src/md/windows/Makefile 
+pr/src/md/${PR_MD_ARCH_DIR}/Makefile 
 pr/src/memory/Makefile 
 pr/src/misc/Makefile 
-pr/src/pthreads/Makefile 
 pr/src/threads/Makefile 
-pr/src/threads/combined/Makefile 
 pr/tests/Makefile 
 pr/tests/dll/Makefile 
-pr/tests/w16gui/Makefile 
-tools/Makefile 
-])
+"
+
+dnl lib/tests/Makefile
+dnl pr/tests/w16gui/Makefile
+dnl tools/Makefile
 
-dnl lib/prstreams/tests/testprstrm/Makefile 
-dnl lib/tests/windows/makefile 
+if test -z "$USE_PTHREADS" && test -z "$USE_BTHREADS"; then
+    MAKEFILES="$MAKEFILES pr/src/threads/combined/Makefile"
+elif test -n "$USE_PTHREADS"; then
+    MAKEFILES="$MAKEFILES pr/src/pthreads/Makefile"
+elif test -n "$USE_BTHREADS"; then
+    MAKEFILES="$MAKEFILES pr/src/bthreads/Makefile"
+fi
+
+if test -n "$USE_CPLUS"; then
+    MAKEFILES="$MAKEFILES pr/src/cplus/Makefile pr/src/cplus/tests/Makefile"
+fi
+
+AC_OUTPUT([$MAKEFILES])
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -24,9 +24,8 @@ export NSPR20=1
 include $(MOD_DEPTH)/config/config.mk
 
 DIRS = ds libc
 
 include $(MOD_DEPTH)/config/rules.mk
 
 export:: $(TARGETS)
 
-install:: export
--- a/lib/Makefile.in
+++ b/lib/Makefile.in
@@ -29,9 +29,8 @@ export NSPR20=1
 include $(topsrcdir)/config/config.mk
 
 DIRS = ds libc
 
 include $(topsrcdir)/config/rules.mk
 
 export:: $(TARGETS)
 
-install:: export
--- a/lib/ds/Makefile
+++ b/lib/ds/Makefile
@@ -23,68 +23,68 @@ include $(MOD_DEPTH)/config/config.mk
 
 # Disable optimization of the nspr on SunOS4.1.3
 ifeq ($(OS_ARCH),SunOS)
 ifeq ($(OS_RELEASE),4.1.3_U1)
 OPTIMIZER =
 endif
 endif
 
-INCLUDES = -I$(DIST)/include -I$(MOD_DEPTH)/pr/include
+INCLUDES = -I$(includedir) -I$(MOD_DEPTH)/pr/include
 
 CSRCS = \
 	plarena.c \
 	plhash.c \
 	plvrsion.c \
 	$(NULL)
 
 HEADERS = \
 	plarenas.h \
 	plarena.h \
 	plhash.h \
 	$(NULL)
 
 ifeq ($(OS_ARCH), WINNT)
 ifeq ($(OS_TARGET), WIN16)
 # OS_CFLAGS = $(OS_EXE_CFLAGS)
-EXTRA_LIBS = $(DIST)/lib/nspr$(MOD_VERSION).$(LIB_SUFFIX)
+EXTRA_LIBS = $(libdir)/nspr$(MOD_VERSION).$(LIB_SUFFIX)
 else
 DLLBASE=/BASE:0x30000000
 RES=$(OBJDIR)/plds.res
 RESNAME=plds.rc
 OS_LIBS = user32.lib
 ifeq ($(OS_TARGET),WIN95)
-EXTRA_LIBS = $(DIST)/lib/nspr$(MOD_VERSION).lib
+EXTRA_LIBS = $(libdir)/nspr$(MOD_VERSION).lib
 else
-EXTRA_LIBS = $(DIST)/lib/libnspr$(MOD_VERSION).lib
+EXTRA_LIBS = $(libdir)/libnspr$(MOD_VERSION).lib
 endif
 
 ifdef MOZ_DEBUG
 ifdef GLOWCODE
 EXTRA_LIBS += $(GLOWDIR)/glowcode.lib
 endif
 endif
 endif
 
 else
 ifeq ($(MOZ_OS2_TOOLS),VACPP)
-EXTRA_LIBS = $(DIST)/lib/nspr$(MOD_VERSION).$(LIB_SUFFIX)
+EXTRA_LIBS = $(libdir)/nspr$(MOD_VERSION).$(LIB_SUFFIX)
 
 else
 ifeq ($(OS_ARCH), AIX)
 ifeq ($(CLASSIC_NSPR),1)
 OS_LIBS += -lc
 else
 OS_LIBS += -lc_r
 endif
 endif
 ifeq ($(OS_ARCH)$(OS_RELEASE), AIX4.1)
-EXTRA_LIBS = -L$(DIST)/lib -lnspr$(MOD_VERSION)_shr
+EXTRA_LIBS = -L$(libdir) -lnspr$(MOD_VERSION)_shr
 else
-EXTRA_LIBS = -L$(DIST)/lib -lnspr$(MOD_VERSION)
+EXTRA_LIBS = -L$(libdir) -lnspr$(MOD_VERSION)
 endif
 endif
 endif
 
 # On NCR and SCOOS, we can't link with extra libraries when
 # we build a shared library.  If we do so, the linker doesn't
 # complain, but we would run into weird problems at run-time.
 # Therefore on these platforms, we link just the .o files.
@@ -141,34 +141,33 @@ else
 	$(CC) -o $@ -c $(CFLAGS) -I$(OBJDIR) plvrsion.c
 endif
 endif
 #
 # Version information generation (end)
 #
 
 #
-# The Client build wants the shared libraries in $(DIST)/bin,
+# The Client build wants the shared libraries in $(bindir),
 # so we also install them there.
 #
 
 export:: $(TARGETS)
-	$(INSTALL) -m 444 $(HEADERS) $(DIST)/include
-	$(INSTALL) -m 444 $(TARGETS) $(DIST)/lib
+	$(INSTALL) -m 444 $(HEADERS) $(includedir)
+	$(INSTALL) -m 444 $(TARGETS) $(libdir)
 ifdef SHARED_LIBRARY
 ifeq ($(OS_ARCH),HP-UX)
-	$(INSTALL) -m 755 $(SHARED_LIBRARY) $(DIST)/lib
-	$(INSTALL) -m 755 $(SHARED_LIBRARY) $(DIST)/bin
+	$(INSTALL) -m 755 $(SHARED_LIBRARY) $(libdir)
+	$(INSTALL) -m 755 $(SHARED_LIBRARY) $(bindir)
 else
-	$(INSTALL) -m 444 $(SHARED_LIBRARY) $(DIST)/bin
+	$(INSTALL) -m 444 $(SHARED_LIBRARY) $(bindir)
 endif
 ifeq ($(OS_ARCH), OpenVMS)
-	$(INSTALL) -m 444 $(SHARED_LIBRARY:.$(DLL_SUFFIX)=.vms) $(DIST)/lib
+	$(INSTALL) -m 444 $(SHARED_LIBRARY:.$(DLL_SUFFIX)=.vms) $(libdir)
 endif
 endif
 ifeq ($(MOZ_BITS),16)
 	$(INSTALL) -m 444 $(HEADERS) $(MOZ_INCL)
 	$(INSTALL) -m 444 $(TARGETS) $(MOZ_DIST)/lib
 	$(INSTALL) -m 444 $(TARGETS) $(MOZ_DIST)/bin
 endif
 
-install:: export
 
--- a/lib/ds/Makefile.in
+++ b/lib/ds/Makefile.in
@@ -30,88 +30,89 @@ ifndef USE_AUTOCONF
 # Disable optimization of the nspr on SunOS4.1.3
 ifeq ($(OS_ARCH),SunOS)
 ifeq ($(OS_RELEASE),4.1.3_U1)
 OPTIMIZER =
 endif
 endif
 endif #!USE_AUTOCONF
 
-INCLUDES = -I$(DIST)/include -I$(topsrcdir)/pr/include
+INCLUDES = -I$(includedir) -I$(topsrcdir)/pr/include
 
 CSRCS = \
 	plarena.c \
 	plhash.c \
 	plvrsion.c \