bug 444686 - create/adapt build system for comm-central, creating the buildsystem, r=ted r=Callek r=Standard8
authorRobert Kaiser <kairo@kairo.at>
Tue, 22 Jul 2008 14:27:55 +0200
changeset 1 66c9c3ea3cbed9214b524d4631cf7bc900e34b8b
parent 0 e4f4569d451a5e0d12a6aa33ebd916f979dd8faa
child 2 c087100cf4cf306023db268640ada54ebb0d4e82
push idunknown
push userunknown
push dateunknown
reviewersted, Callek, Standard8
bugs444686
bug 444686 - create/adapt build system for comm-central, creating the buildsystem, r=ted r=Callek r=Standard8
.hgignore
Makefile.in
aclocal.m4
allmakefiles.sh
build/macosx/universal/flight.mk
client.mk
client.py
config/autoconf.mk.in
config/config.mk
config/rules.mk
config/static-config.mk
config/static-rules.mk
config/version.mk
configure.in
new file mode 100644
--- /dev/null
+++ b/.hgignore
@@ -0,0 +1,25 @@
+# .hgignore - List of filenames hg should ignore
+
+# Filenames that should be ignored wherever they appear
+~$
+\.pyc$
+(^|/)TAGS$
+
+# User files that may appear at the root
+^\.mozconfig$
+^mozconfig$
+^\.mozconfig\.mk$
+^\.mozconfig\.out$
+^configure$
+^config\.cache$
+^config\.log$
+^ID$
+
+# Build directories
+^obj-
+^objdir-
+
+# directories we check out from other repositories
+^calendar$
+^directory/c-sdk$
+^mozilla$
new file mode 100644
--- /dev/null
+++ b/Makefile.in
@@ -0,0 +1,49 @@
+# ***** BEGIN LICENSE BLOCK *****
+# Version: MPL 1.1/GPL 2.0/LGPL 2.1
+#
+# The contents of this file are subject to the Mozilla Public License Version
+# 1.1 (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+# http://www.mozilla.org/MPL/
+#
+# Software distributed under the License is distributed on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+# for the specific language governing rights and limitations under the
+# License.
+#
+# The Original Code is mozilla.org code.
+#
+# The Initial Developer of the Original Code is
+# Netscape Communications Corporation.
+# Portions created by the Initial Developer are Copyright (C) 1998
+# the Initial Developer. All Rights Reserved.
+#
+# Contributor(s):
+#
+# Alternatively, the contents of this file may be used under the terms of
+# either the GNU General Public License Version 2 or later (the "GPL"), or
+# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+# in which case the provisions of the GPL or the LGPL are applicable instead
+# of those above. If you wish to allow use of your version of this file only
+# under the terms of either the GPL or the LGPL, and not to allow others to
+# use your version of this file under the terms of the MPL, indicate your
+# decision by deleting the provisions above and replace them with the notice
+# and other provisions required by the GPL or the LGPL. If you do not delete
+# the provisions above, a recipient may use your version of this file under
+# the terms of any one of the MPL, the GPL or the LGPL.
+#
+# ***** END LICENSE BLOCK *****
+
+DEPTH		= .
+topsrcdir	= @top_srcdir@
+srcdir		= @srcdir@
+VPATH		= @srcdir@
+
+include $(topsrcdir)/config/config.mk
+
+default install export libs clean realclean distclean alldep maybe_clobber_profiledbuild check rebase splitsymbols buildsymbols uploadsymbols signnss deliver::
+	$(MAKE) -C mozilla $@
+
+include $(topsrcdir)/$(MOZ_BUILD_APP)/build.mk
+
+include $(topsrcdir)/config/rules.mk
new file mode 100644
--- /dev/null
+++ b/aclocal.m4
@@ -0,0 +1,18 @@
+dnl
+dnl Local autoconf macros used with mozilla
+dnl The contents of this file are under the Public Domain.
+dnl 
+
+builtin(include, mozilla/build/autoconf/glib.m4)dnl
+builtin(include, mozilla/build/autoconf/gtk.m4)dnl
+builtin(include, mozilla/build/autoconf/libIDL.m4)dnl
+builtin(include, mozilla/build/autoconf/libIDL-2.m4)dnl
+builtin(include, mozilla/build/autoconf/nspr.m4)dnl
+builtin(include, mozilla/build/autoconf/nss.m4)dnl
+builtin(include, mozilla/build/autoconf/libart.m4)dnl
+builtin(include, mozilla/build/autoconf/pkg.m4)dnl
+builtin(include, mozilla/build/autoconf/freetype2.m4)dnl
+builtin(include, mozilla/build/autoconf/codeset.m4)dnl
+dnl
+define(MOZ_TOPSRCDIR,mozilla)dnl MOZ_TOPSRCDIR is used in altoptions.m4
+builtin(include, mozilla/build/autoconf/altoptions.m4)dnl
new file mode 100755
--- /dev/null
+++ b/allmakefiles.sh
@@ -0,0 +1,81 @@
+#! /bin/sh
+#
+# ***** BEGIN LICENSE BLOCK *****
+# Version: MPL 1.1/GPL 2.0/LGPL 2.1
+#
+# The contents of this file are subject to the Mozilla Public License Version
+# 1.1 (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+# http://www.mozilla.org/MPL/
+#
+# Software distributed under the License is distributed on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+# for the specific language governing rights and limitations under the
+# License.
+#
+# The Original Code is mozilla.org code.
+#
+# The Initial Developer of the Original Code is
+# Netscape Communications Corporation.
+# Portions created by the Initial Developer are Copyright (C) 1999
+# the Initial Developer. All Rights Reserved.
+#
+# Contributor(s):
+#
+# Alternatively, the contents of this file may be used under the terms of
+# either the GNU General Public License Version 2 or later (the "GPL"), or
+# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+# in which case the provisions of the GPL or the LGPL are applicable instead
+# of those above. If you wish to allow use of your version of this file only
+# under the terms of either the GPL or the LGPL, and not to allow others to
+# use your version of this file under the terms of the MPL, indicate your
+# decision by deleting the provisions above and replace them with the notice
+# and other provisions required by the GPL or the LGPL. If you do not delete
+# the provisions above, a recipient may use your version of this file under
+# the terms of any one of the MPL, the GPL or the LGPL.
+#
+# ***** END LICENSE BLOCK *****
+
+# allmakefiles.sh - List of all makefiles.
+#   Appends the list of makefiles to the variable, MAKEFILES.
+#   There is no need to rerun autoconf after adding makefiles.
+#   You only need to run configure.
+
+MAKEFILES=""
+
+# add_makefiles - Shell function to add makefiles to MAKEFILES
+add_makefiles() {
+  MAKEFILES="$MAKEFILES $*"
+}
+
+if [ "$srcdir" = "" ]; then
+  srcdir=.
+fi
+
+#
+# Common makefiles used by everyone
+#
+add_makefiles "
+Makefile
+config/autoconf.mk
+"
+
+if [ "$MOZ_LDAP_XPCOM" ]; then
+  . "${srcdir}/directory/makefiles.sh"
+fi
+
+if [ "$MOZ_MAIL_NEWS" ]; then
+  . "${srcdir}/mailnews/makefiles.sh"
+fi
+
+if [ "$MOZ_CALENDAR" ]; then
+  . "${srcdir}/calendar/shared_makefiles.sh"
+  . "${srcdir}/calendar/lightning/makefiles.sh"
+fi
+
+#
+# Application-specific makefiles
+#
+if test -f "${srcdir}/${MOZ_BUILD_APP}/makefiles.sh"; then
+  . "${srcdir}/${MOZ_BUILD_APP}/makefiles.sh"
+fi
new file mode 100644
--- /dev/null
+++ b/build/macosx/universal/flight.mk
@@ -0,0 +1,100 @@
+# ***** BEGIN LICENSE BLOCK *****
+# Version: MPL 1.1/GPL 2.0/LGPL 2.1
+#
+# The contents of this file are subject to the Mozilla Public License Version
+# 1.1 (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+# http://www.mozilla.org/MPL/
+#
+# Software distributed under the License is distributed on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+# for the specific language governing rights and limitations under the
+# License.
+#
+# The Original Code is the Mozilla Mac OS X Universal Binary Packaging System
+#
+# The Initial Developer of the Original Code is Google Inc.
+# Portions created by the Initial Developer are Copyright (C) 2006
+# the Initial Developer. All Rights Reserved.
+#
+# Contributor(s):
+#  Mark Mentovai <mark@moxienet.com> (Original Author)
+#
+# Alternatively, the contents of this file may be used under the terms of
+# either the GNU General Public License Version 2 or later (the "GPL"), or
+# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+# in which case the provisions of the GPL or the LGPL are applicable instead
+# of those above. If you wish to allow use of your version of this file only
+# under the terms of either the GPL or the LGPL, and not to allow others to
+# use your version of this file under the terms of the MPL, indicate your
+# decision by deleting the provisions above and replace them with the notice
+# and other provisions required by the GPL or the LGPL. If you do not delete
+# the provisions above, a recipient may use your version of this file under
+# the terms of any one of the MPL, the GPL or the LGPL.
+#
+# ***** END LICENSE BLOCK *****
+
+# BE CAREFUL!  This makefile handles a postflight_all rule for a
+# multi-project build, so DON'T rely on anything that might differ between
+# the two OBJDIRs.
+
+ifndef OBJDIR
+OBJDIR_PPC = $(MOZ_OBJDIR)/ppc
+OBJDIR_X86 = $(MOZ_OBJDIR)/i386
+DIST_PPC = $(OBJDIR_PPC)/mozilla/dist
+DIST_X86 = $(OBJDIR_X86)/mozilla/dist
+DIST_UNI = $(DIST_PPC)/universal
+OBJDIR = $(OBJDIR_PPC)
+endif
+
+include $(OBJDIR)/config/autoconf.mk
+
+DIST = $(OBJDIR)/mozilla/dist
+
+ifdef MOZ_DEBUG
+DBGTAG = Debug
+else
+DBGTAG =
+endif
+
+ifdef LIBXUL_SDK # {
+APP_CONTENTS = Contents/Frameworks/XUL.framework
+else # } {
+APP_CONTENTS = Contents/MacOS
+endif # } LIBXUL_SDK
+
+MOZ_PKG_APPNAME = $(MOZ_APP_NAME)
+APPNAME = $(MOZ_APP_DISPLAYNAME)$(DBGTAG).app
+INSTALLER_DIR = $(MOZ_BUILD_APP)/installer
+BUILDCONFIG_JAR = $(APP_CONTENTS)/chrome/toolkit.jar
+
+postflight_all:
+# Build the universal package out of only the bits that would be released.
+# Call the packager to set this up.  Set UNIVERSAL_BINARY= to avoid producing
+# a universal binary too early, before the unified bits have been staged.
+# Set SIGN_NSS= to skip shlibsign.
+	$(MAKE) -C $(OBJDIR_PPC)/$(INSTALLER_DIR) \
+          UNIVERSAL_BINARY= SIGN_NSS= PKG_SKIP_STRIP=1 stage-package
+	$(MAKE) -C $(OBJDIR_X86)/$(INSTALLER_DIR) \
+          UNIVERSAL_BINARY= SIGN_NSS= PKG_SKIP_STRIP=1 stage-package
+# Remove .chk files that may have been copied from the NSS build.  These will
+# cause unify to warn or fail if present.  New .chk files that are
+# appropriate for the merged libraries will be generated when the universal
+# dmg is built.
+	rm -f $(DIST_PPC)/$(MOZ_PKG_APPNAME)/$(APPNAME)/$(APP_CONTENTS)/*.chk \
+	      $(DIST_X86)/$(MOZ_PKG_APPNAME)/$(APPNAME)/$(APP_CONTENTS)/*.chk
+# The only difference betewen the two trees now should be the
+# about:buildconfig page.  Fix it up.
+	$(TOPSRCDIR)/mozilla/build/macosx/universal/fix-buildconfig \
+	  $(DIST_PPC)/$(MOZ_PKG_APPNAME)/$(APPNAME)/$(BUILDCONFIG_JAR) \
+	  $(DIST_X86)/$(MOZ_PKG_APPNAME)/$(APPNAME)/$(BUILDCONFIG_JAR)
+	mkdir -p $(DIST_UNI)/$(MOZ_PKG_APPNAME)
+	rm -f $(DIST_X86)/universal
+	ln -s $(DIST_UNI) $(DIST_X86)/universal
+	rm -rf $(DIST_UNI)/$(MOZ_PKG_APPNAME)/$(APPNAME)
+	$(TOPSRCDIR)/mozilla/build/macosx/universal/unify \
+	  $(DIST_PPC)/$(MOZ_PKG_APPNAME)/$(APPNAME) \
+	  $(DIST_X86)/$(MOZ_PKG_APPNAME)/$(APPNAME) \
+	  $(DIST_UNI)/$(MOZ_PKG_APPNAME)/$(APPNAME)
+# A universal .dmg can now be produced by making in either architecture's
+# INSTALLER_DIR.
new file mode 100644
--- /dev/null
+++ b/client.mk
@@ -0,0 +1,386 @@
+# ***** BEGIN LICENSE BLOCK *****
+# Version: MPL 1.1/GPL 2.0/LGPL 2.1
+#
+# The contents of this file are subject to the Mozilla Public License Version
+# 1.1 (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+# http://www.mozilla.org/MPL/
+#
+# Software distributed under the License is distributed on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+# for the specific language governing rights and limitations under the
+# License.
+#
+# The Original Code is mozilla.org code.
+#
+# The Initial Developer of the Original Code is
+# Netscape Communications Corporation.
+# Portions created by the Initial Developer are Copyright (C) 1998
+# the Initial Developer. All Rights Reserved.
+#
+# Contributor(s):
+#   Stephen Lamm
+#   Benjamin Smedberg <bsmedberg@covad.net>
+#   Chase Phillips <chase@mozilla.org>
+#   Mark Mentovai <mark@moxienet.com>
+#   Robert Kaiser <kairo@kairo.at>
+#
+# Alternatively, the contents of this file may be used under the terms of
+# either the GNU General Public License Version 2 or later (the "GPL"), or
+# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+# in which case the provisions of the GPL or the LGPL are applicable instead
+# of those above. If you wish to allow use of your version of this file only
+# under the terms of either the GPL or the LGPL, and not to allow others to
+# use your version of this file under the terms of the MPL, indicate your
+# decision by deleting the provisions above and replace them with the notice
+# and other provisions required by the GPL or the LGPL. If you do not delete
+# the provisions above, a recipient may use your version of this file under
+# the terms of any one of the MPL, the GPL or the LGPL.
+#
+# ***** END LICENSE BLOCK *****
+
+# Build a comm application (Mozilla calendar, mail or suite).
+#
+# To build a tree,
+#    1. hg clone http://hg.mozilla.org/comm-central comm
+#    2. cd comm
+#    3. python client.py checkout
+#    4. create your .mozconfig file with
+#       ac_add_options --enable-application=suite
+#         (or mail, or calendar)
+#    5. gmake -f client.mk
+#
+# Other targets (gmake -f client.mk [targets...]),
+#    build
+#    clean
+#    distclean
+#
+# See http://developer.mozilla.org/en/docs/Build_Documentation for 
+# more information.
+#
+# Options:
+#   MOZ_BUILD_PROJECTS   - Build multiple projects in subdirectories
+#                          of MOZ_OBJDIR
+#   MOZ_OBJDIR           - Destination object directory
+#   MOZ_MAKE_FLAGS       - Flags to pass to $(MAKE)
+#   MOZ_PREFLIGHT_ALL  } - Makefiles to run before any project in
+#   MOZ_PREFLIGHT      }   MOZ_BUILD_PROJECTS, before each project, after
+#   MOZ_POSTFLIGHT     }   each project, and after all projects; these
+#   MOZ_POSTFLIGHT_ALL }   variables contain space-separated lists
+#   MOZ_UNIFY_BDATE      - Set to use the same bdate for each project in
+#                          MOZ_BUILD_PROJECTS
+#
+#######################################################################
+# Defines
+
+comma := ,
+
+CWD := $(shell pwd)
+ifneq (1,$(words $(CWD)))
+$(error The mozilla directory cannot be located in a path with spaces.)
+endif
+
+ifeq "$(CWD)" "/"
+CWD   := /.
+endif
+
+ifndef TOPSRCDIR
+ifeq (,$(wildcard client.mk))
+$(error Must run from the client.mk directory, or specify TOPSRCDIR)
+endif
+TOPSRCDIR = $(CWD)
+endif
+
+ifeq (Darwin,$(shell uname -s))
+AUTOCONF ?= autoconf213
+else
+AUTOCONF ?= autoconf-2.13
+endif
+
+MKDIR := mkdir
+SH := /bin/sh
+ifndef MAKE
+MAKE := gmake
+endif
+PERL ?= perl
+PYTHON ?= python
+
+CONFIG_GUESS_SCRIPT := $(wildcard $(TOPSRCDIR)/mozilla/build/autoconf/config.guess)
+ifdef CONFIG_GUESS_SCRIPT
+  CONFIG_GUESS = $(shell $(CONFIG_GUESS_SCRIPT))
+endif
+
+
+####################################
+# Sanity checks
+
+ifneq (,$(filter MINGW%,$(shell uname -s)))
+# check for CRLF line endings
+ifneq (0,$(shell $(PERL) -e 'binmode(STDIN); while (<STDIN>) { if (/\r/) { print "1"; exit } } print "0"' < $(TOPSRCDIR)/client.mk))
+$(error This source tree appears to have Windows-style line endings. To \
+convert it to Unix-style line endings, run \
+"python mozilla/build/win32/mozilla-dos2unix.py")
+endif
+endif
+
+####################################
+# Load mozconfig Options
+
+# See build pages, http://www.mozilla.org/build/ for how to set up mozconfig.
+
+MOZCONFIG_LOADER := mozilla/build/autoconf/mozconfig2client-mk
+MOZCONFIG_FINDER := mozilla/build/autoconf/mozconfig-find
+MOZCONFIG_MODULES := mozilla/build/unix/uniq.pl
+
+run_for_side_effects := \
+  $(shell $(TOPSRCDIR)/$(MOZCONFIG_LOADER) $(TOPSRCDIR) $(TOPSRCDIR)/.mozconfig.mk > $(TOPSRCDIR)/.mozconfig.out)
+
+include $(TOPSRCDIR)/.mozconfig.mk
+
+ifdef MOZ_BUILD_PROJECTS
+
+ifndef MOZ_OBJDIR
+  $(error When MOZ_BUILD_PROJECTS is set, you must set MOZ_OBJDIR)
+endif
+ifdef MOZ_CURRENT_PROJECT
+  OBJDIR = $(MOZ_OBJDIR)/$(MOZ_CURRENT_PROJECT)
+  MOZ_MAKE = $(MAKE) $(MOZ_MAKE_FLAGS) -C $(OBJDIR)
+  BUILD_PROJECT_ARG = MOZ_BUILD_APP=$(MOZ_CURRENT_PROJECT)
+else
+  OBJDIR = $(error Cannot find the OBJDIR when MOZ_CURRENT_PROJECT is not set.)
+  MOZ_MAKE = $(error Cannot build in the OBJDIR when MOZ_CURRENT_PROJECT is not set.)
+endif
+
+else # MOZ_BUILD_PROJECTS
+
+ifdef MOZ_OBJDIR
+  OBJDIR = $(MOZ_OBJDIR)
+  MOZ_MAKE = $(MAKE) $(MOZ_MAKE_FLAGS) -C $(OBJDIR)
+else
+  OBJDIR := $(TOPSRCDIR)
+  MOZ_MAKE := $(MAKE) $(MOZ_MAKE_FLAGS)
+endif
+
+endif # MOZ_BUILD_PROJECTS
+
+CONFIGURES := $(TOPSRCDIR)/configure $(TOPSRCDIR)/mozilla/configure
+
+#######################################################################
+# Rules
+
+# The default rule is build
+build::
+
+# Print out any options loaded from mozconfig.
+all build clean depend distclean export libs install realclean::
+	@if test -f .mozconfig.out; then \
+	  cat .mozconfig.out; \
+	  rm -f .mozconfig.out; \
+	else true; \
+	fi
+
+# Windows equivalents
+build_all: build
+build_all_dep: alldep
+build_all_depend: alldep
+clobber clobber_all: clean
+
+# Do everything from scratch
+everything: clean build
+
+#####################################################
+# Build date unification
+
+ifdef MOZ_UNIFY_BDATE
+ifndef MOZ_BUILD_DATE
+ifdef MOZ_BUILD_PROJECTS
+MOZ_BUILD_DATE = $(shell $(PYTHON) $(TOPSRCDIR)/mozilla/toolkit/xre/make-platformini.py --print-buildid)
+export MOZ_BUILD_DATE
+endif
+endif
+endif
+
+#####################################################
+# Preflight, before building any project
+
+build alldep preflight_all::
+ifeq (,$(MOZ_CURRENT_PROJECT)$(if $(MOZ_PREFLIGHT_ALL),,1))
+# Don't run preflight_all for individual projects in multi-project builds
+# (when MOZ_CURRENT_PROJECT is set.)
+ifndef MOZ_BUILD_PROJECTS
+# Building a single project, OBJDIR is usable.
+	set -e; \
+	for mkfile in $(MOZ_PREFLIGHT_ALL); do \
+	  $(MAKE) -f $(TOPSRCDIR)/$$mkfile preflight_all TOPSRCDIR=$(TOPSRCDIR) OBJDIR=$(OBJDIR) MOZ_OBJDIR=$(MOZ_OBJDIR); \
+	done
+else
+# OBJDIR refers to the project-specific OBJDIR, which is not available at
+# this point when building multiple projects.  Only MOZ_OBJDIR is available.
+	set -e; \
+	for mkfile in $(MOZ_PREFLIGHT_ALL); do \
+	  $(MAKE) -f $(TOPSRCDIR)/$$mkfile preflight_all TOPSRCDIR=$(TOPSRCDIR) MOZ_OBJDIR=$(MOZ_OBJDIR) MOZ_BUILD_PROJECTS="$(MOZ_BUILD_PROJECTS)"; \
+	done
+endif
+endif
+
+# If we're building multiple projects, but haven't specified which project,
+# loop through them.
+
+ifeq (,$(MOZ_CURRENT_PROJECT)$(if $(MOZ_BUILD_PROJECTS),,1))
+configure depend build install export libs clean realclean distclean alldep preflight postflight maybe_clobber_profiledbuild::
+	set -e; \
+	for app in $(MOZ_BUILD_PROJECTS); do \
+	  $(MAKE) -f $(TOPSRCDIR)/client.mk $@ MOZ_CURRENT_PROJECT=$$app; \
+	done
+
+else
+
+# MOZ_CURRENT_PROJECT: either doing a single-project build, or building an
+# individual project in a multi-project build.
+
+####################################
+# Configure
+
+CONFIG_STATUS = $(wildcard $(OBJDIR)/config.status)
+CONFIG_CACHE  = $(wildcard $(OBJDIR)/config.cache)
+
+EXTRA_CONFIG_DEPS := \
+	$(TOPSRCDIR)/aclocal.m4 \
+	$(TOPSRCDIR)/mozilla/aclocal.m4 \
+	$(wildcard $(TOPSRCDIR)/mozilla/build/autoconf/*.m4) \
+	$(NULL)
+
+$(TOPSRCDIR)/configure: $(TOPSRCDIR)/configure.in $(EXTRA_CONFIG_DEPS)
+	@echo Generating $@ using autoconf
+	cd $(TOPSRCDIR); $(AUTOCONF)
+
+$(TOPSRCDIR)/mozilla/configure: $(TOPSRCDIR)/mozilla/configure.in $(EXTRA_CONFIG_DEPS)
+	@echo Generating $@ using autoconf
+	cd $(TOPSRCDIR)/mozilla; $(AUTOCONF)
+
+CONFIG_STATUS_DEPS := \
+	$(TOPSRCDIR)/configure \
+	$(TOPSRCDIR)/allmakefiles.sh \
+	$(TOPSRCDIR)/.mozconfig.mk \
+	$(TOPSRCDIR)/mozilla/configure \
+	$(TOPSRCDIR)/mozilla/allmakefiles.sh \
+	$(wildcard $(TOPSRCDIR)/mozilla/nsprpub/configure) \
+	$(wildcard $(TOPSRCDIR)/mozilla/config/milestone.txt) \
+	$(wildcard $(TOPSRCDIR)/directory/c-sdk/configure) \
+	$(wildcard $(addsuffix confvars.sh,$(wildcard $(TOPSRCDIR)/*/))) \
+	$(NULL)
+
+# configure uses the program name to determine @srcdir@. Calling it without
+#   $(TOPSRCDIR) will set @srcdir@ to "."; otherwise, it is set to the full
+#   path of $(TOPSRCDIR).
+ifeq ($(TOPSRCDIR),$(OBJDIR))
+  CONFIGURE = ./configure
+else
+  CONFIGURE = $(TOPSRCDIR)/configure
+endif
+
+configure:: $(CONFIGURES)
+ifdef MOZ_BUILD_PROJECTS
+	@if test ! -d $(MOZ_OBJDIR); then $(MKDIR) $(MOZ_OBJDIR); else true; fi
+	export MOZ_CURRENT_PROJECT
+endif
+	@if test ! -d $(OBJDIR); then $(MKDIR) $(OBJDIR); else true; fi
+	@echo cd $(OBJDIR);
+	@echo $(CONFIGURE) $(CONFIGURE_ARGS)
+	@cd $(OBJDIR) && $(BUILD_PROJECT_ARG) $(CONFIGURE_ENV_ARGS) $(CONFIGURE) $(CONFIGURE_ARGS) \
+	  || ( echo "*** Fix above errors and then restart with\
+               \"$(MAKE) -f client.mk build\"" && exit 1 )
+	@touch $(OBJDIR)/Makefile
+
+$(OBJDIR)/Makefile $(OBJDIR)/config.status: $(CONFIG_STATUS_DEPS)
+	@$(MAKE) -f $(TOPSRCDIR)/client.mk configure
+
+ifneq (,$(CONFIG_STATUS))
+$(OBJDIR)/config/autoconf.mk: $(TOPSRCDIR)/config/autoconf.mk.in
+	cd $(OBJDIR); \
+	  CONFIG_FILES=config/autoconf.mk ./config.status
+endif
+
+
+####################################
+# Depend
+
+depend:: $(OBJDIR)/Makefile $(OBJDIR)/config.status
+	$(MOZ_MAKE) export && $(MOZ_MAKE) depend
+
+####################################
+# Preflight
+
+build alldep preflight::
+ifdef MOZ_PREFLIGHT
+	set -e; \
+	for mkfile in $(MOZ_PREFLIGHT); do \
+	  $(MAKE) -f $(TOPSRCDIR)/$$mkfile preflight TOPSRCDIR=$(TOPSRCDIR) OBJDIR=$(OBJDIR) MOZ_OBJDIR=$(MOZ_OBJDIR); \
+	done
+endif
+
+####################################
+# Build it
+
+build::  $(OBJDIR)/Makefile $(OBJDIR)/config.status
+	$(MOZ_MAKE)
+
+####################################
+# Other targets
+
+# Pass these target onto the real build system
+install export libs clean realclean distclean alldep:: $(OBJDIR)/Makefile $(OBJDIR)/config.status
+	$(MOZ_MAKE) $@
+
+####################################
+# Postflight
+
+build alldep postflight::
+ifdef MOZ_POSTFLIGHT
+	set -e; \
+	for mkfile in $(MOZ_POSTFLIGHT); do \
+	  $(MAKE) -f $(TOPSRCDIR)/$$mkfile postflight TOPSRCDIR=$(TOPSRCDIR) OBJDIR=$(OBJDIR) MOZ_OBJDIR=$(MOZ_OBJDIR); \
+	done
+endif
+
+endif # MOZ_CURRENT_PROJECT
+
+####################################
+# Postflight, after building all projects
+
+build alldep postflight_all::
+ifeq (,$(MOZ_CURRENT_PROJECT)$(if $(MOZ_POSTFLIGHT_ALL),,1))
+# Don't run postflight_all for individual projects in multi-project builds
+# (when MOZ_CURRENT_PROJECT is set.)
+ifndef MOZ_BUILD_PROJECTS
+# Building a single project, OBJDIR is usable.
+	set -e; \
+	for mkfile in $(MOZ_POSTFLIGHT_ALL); do \
+	  $(MAKE) -f $(TOPSRCDIR)/$$mkfile postflight_all TOPSRCDIR=$(TOPSRCDIR) OBJDIR=$(OBJDIR) MOZ_OBJDIR=$(MOZ_OBJDIR); \
+	done
+else
+# OBJDIR refers to the project-specific OBJDIR, which is not available at
+# this point when building multiple projects.  Only MOZ_OBJDIR is available.
+	set -e; \
+	for mkfile in $(MOZ_POSTFLIGHT_ALL); do \
+	  $(MAKE) -f $(TOPSRCDIR)/$$mkfile postflight_all TOPSRCDIR=$(TOPSRCDIR) MOZ_OBJDIR=$(MOZ_OBJDIR) MOZ_BUILD_PROJECTS="$(MOZ_BUILD_PROJECTS)"; \
+	done
+endif
+endif
+
+cleansrcdir:
+	@cd $(TOPSRCDIR); \
+	if [ -f Makefile ]; then \
+	  $(MAKE) distclean ; \
+	else \
+	  echo "Removing object files from srcdir..."; \
+	  rm -fr `find . -type d \( -name .deps -print -o -name CVS \
+	          -o -exec test ! -d {}/CVS \; \) -prune \
+	          -o \( -name '*.[ao]' -o -name '*.so' \) -type f -print`; \
+	   build/autoconf/clean-config.sh; \
+	fi;
+
+echo-variable-%:
+	@echo $($*)
+
+.PHONY: checkout real_checkout depend build export libs alldep install clean realclean distclean cleansrcdir pull_all build_all clobber clobber_all pull_and_build_all everything configure preflight_all preflight postflight postflight_all
new file mode 100644
--- /dev/null
+++ b/client.py
@@ -0,0 +1,173 @@
+#!/usr/bin/python
+
+CVS_CO_TAG = 'HEAD'
+EXTENSION_CO_TAG = 'HEAD'
+LDAPCSDK_CO_TAG = 'LDAPCSDK_6_0_3_CLIENT_BRANCH'
+
+CHATZILLA_CO_TAG = 'HEAD'
+VENKMAN_CO_TAG = 'HEAD'
+
+CVS_DIRS = ('calendar',)
+EXTENSION_DIRS = ('extensions/typeaheadfind',
+                  'extensions/wallet',
+                  'extensions/webdav',)
+LDAPCSDK_DIRS = ('directory/c-sdk',)
+
+CHATZILLA_DIRS = ('extensions/irc',)
+VENKMAN_DIRS = ('extensions/venkman',)
+
+# URL of the default hg repository to clone for Mozilla.
+DEFAULT_MOZILLA_REPO = 'http://hg.mozilla.org/mozilla-central/'
+
+import os
+import sys
+import datetime
+from optparse import OptionParser
+
+topsrcdir = os.path.dirname(__file__)
+if topsrcdir == '':
+    topsrcdir = '.'
+
+try:
+    from subprocess import check_call
+except ImportError:
+    import subprocess
+    def check_call(*popenargs, **kwargs):
+        retcode = subprocess.call(*popenargs, **kwargs)
+        if retcode:
+            cmd = kwargs.get("args")
+            if cmd is None:
+                cmd = popenargs[0]
+                raise Exception("Command '%s' returned non-zero exit status %i" % (cmd, retcode))
+
+def check_call_noisy(cmd, *args, **kwargs):
+    print "Executing command:", cmd
+    check_call(cmd, *args, **kwargs)
+
+def do_hg_pull(dir, repository, hg):
+    fulldir = os.path.join(topsrcdir, dir)
+    # clone if the dir doesn't exist, pull if it does
+    if not os.path.exists(fulldir):
+        fulldir = os.path.join(topsrcdir, dir)
+        check_call_noisy([hg, 'clone', repository, fulldir])
+    else:
+        cmd = [hg, 'pull', '-u', '-R', fulldir]
+        if repository is not None:
+            cmd.append(repository)
+        check_call_noisy(cmd)
+    check_call([hg, 'parent', '-R', fulldir,
+                '--template=Updated to revision {node}.\n'])
+
+def do_cvs_checkout(modules, tag, cvsroot, cvs, checkoutdir):
+    """Check out a CVS directory into the mozilla/ subdirectory.
+    modules is a list of directories to check out, e.g. ['extensions/irc']
+    """
+    for module in modules:
+        (parent, leaf) = os.path.split(module)
+        print "CVS checkout begin: " + datetime.datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S UTC")
+        check_call_noisy([cvs, '-d', cvsroot, '-q',
+                          'checkout', '-P', '-r', tag, '-d', leaf,
+                          'mozilla/%s' % module],
+                         cwd=os.path.join(topsrcdir, checkoutdir, parent))
+        print "CVS checkout end: " + datetime.datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S UTC")
+
+o = OptionParser(usage="client.py [options] checkout")
+o.add_option("-m", "--comm-repo", dest="comm_repo",
+             default=None,
+             help="URL of comm (Calendar/Mail/Suite) repository to pull from (default: use hg default in .hg/hgrc)")
+o.add_option("--skip-comm", dest="skip_comm",
+             action="store_true", default=False,
+             help="Skip pulling the comm (Calendar/Mail/Suite) repository.")
+
+o.add_option("-z", "--mozilla-repo", dest="mozilla_repo",
+             default=None,
+             help="URL of Mozilla repository to pull from (default: use hg default in mozilla/.hg/hgrc; or if that file doesn't exist, use \"" + DEFAULT_MOZILLA_REPO + "\".)")
+o.add_option("--skip-mozilla", dest="skip_mozilla",
+             action="store_true", default=False,
+             help="Skip pulling the Mozilla repository.")
+
+o.add_option("--skip-cvs", dest="skip_cvs",
+             action="store_true", default=False,
+             help="Skip pulling the old directories from the Mozilla CVS repository.")
+o.add_option("--skip-chatzilla", dest="skip_chatzilla",
+             action="store_true", default=False,
+             help="Skip pulling the ChatZilla repository.")
+o.add_option("--skip-venkman", dest="skip_venkman",
+             action="store_true", default=False,
+             help="Skip pulling the Venkman repository.")
+o.add_option("--skip-calendar", dest="skip_calendar",
+             action="store_true", default=False,
+             help="Skip pulling the Calendar repository.")
+
+o.add_option("--hg", dest="hg", default=os.environ.get('HG', 'hg'),
+             help="The location of the hg binary")
+o.add_option("--cvs", dest="cvs", default=os.environ.get('CVS', 'cvs'),
+             help="The location of the cvs binary")
+o.add_option("--cvsroot", dest="cvsroot",
+             default=os.environ.get('CVSROOT', ':pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot'),
+             help="The CVSROOT (default: :pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot")
+
+
+def fixup_repo_options(options):
+    """ Check options.comm_repo and options.mozilla_repo values;
+    populate mozilla_repo if needed.
+
+    options.comm_repo and options.mozilla_repo are normally None.
+    This is fine-- our "hg pull" commands will omit the repo URL.
+    The exception is the initial checkout, which does an "hg clone"
+    for Mozilla.  That command requires a repository URL.
+    """
+
+    if (options.comm_repo is None
+            and not os.path.exists(os.path.join(topsrcdir, '.hg'))):
+        o.print_help()
+        print
+        print "*** The -m option is required for the initial checkout."
+        sys.exit(2)
+
+    # Handle special case: initial checkout of Mozilla.
+    if (options.mozilla_repo is None
+            and not os.path.exists(os.path.join(topsrcdir, 'mozilla'))):
+        options.mozilla_repo = DEFAULT_MOZILLA_REPO
+
+try:
+    (options, (action,)) = o.parse_args()
+except ValueError:
+    o.print_help()
+    sys.exit(2)
+
+fixup_repo_options(options)
+
+if action in ('checkout', 'co'):
+    if not options.skip_comm:
+        do_hg_pull('.', options.comm_repo, options.hg)
+
+    if not options.skip_mozilla:
+        do_hg_pull('mozilla', options.mozilla_repo, options.hg)
+
+    if not options.skip_cvs:
+        do_cvs_checkout(CVS_DIRS, CVS_CO_TAG, options.cvsroot, options.cvs, '')
+        do_cvs_checkout(LDAPCSDK_DIRS, LDAPCSDK_CO_TAG, options.cvsroot, options.cvs, '')
+        if os.path.exists(os.path.join(topsrcdir, 'mozilla', 'extensions')):
+          do_cvs_checkout(EXTENSION_DIRS, EXTENSION_CO_TAG, options.cvsroot, options.cvs, 'mozilla')
+        else:
+          print >>sys.stderr, "Warning: mozilla/extensions does not exist, built-in extensions could not be checked out."
+          pass
+
+    if not options.skip_chatzilla:
+        if os.path.exists(os.path.join(topsrcdir, 'mozilla', 'extensions')):
+          do_cvs_checkout(CHATZILLA_DIRS, CHATZILLA_CO_TAG, options.cvsroot, options.cvs, 'mozilla')
+        else:
+          print >>sys.stderr, "Warning: mozilla/extensions does not exist, ChatZilla could not be checked out."
+          pass
+
+    if not options.skip_venkman:
+        if os.path.exists(os.path.join(topsrcdir, 'mozilla', 'extensions')):
+          do_cvs_checkout(VENKMAN_DIRS, VENKMAN_CO_TAG, options.cvsroot, options.cvs, 'mozilla')
+        else:
+          print >>sys.stderr, "Warning: mozilla/extensions does not exist, ChatZilla could not be checked out."
+          pass
+
+else:
+    o.print_help()
+    sys.exit(2)
new file mode 100644
--- /dev/null
+++ b/config/autoconf.mk.in
@@ -0,0 +1,614 @@
+#
+# ***** BEGIN LICENSE BLOCK *****
+# Version: MPL 1.1/GPL 2.0/LGPL 2.1
+#
+# The contents of this file are subject to the Mozilla Public License Version
+# 1.1 (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+# http://www.mozilla.org/MPL/
+#
+# Software distributed under the License is distributed on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+# for the specific language governing rights and limitations under the
+# License.
+#
+# The Original Code is this file as it was released upon August 6, 1998.
+#
+# The Initial Developer of the Original Code is
+# Christopher Seawood.
+# Portions created by the Initial Developer are Copyright (C) 1998
+# the Initial Developer. All Rights Reserved.
+#
+# Contributor(s):
+#   Benjamin Smedberg <benjamin@smedbergs.us>
+#
+# Alternatively, the contents of this file may be used under the terms of
+# either of the GNU General Public License Version 2 or later (the "GPL"),
+# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+# in which case the provisions of the GPL or the LGPL are applicable instead
+# of those above. If you wish to allow use of your version of this file only
+# under the terms of either the GPL or the LGPL, and not to allow others to
+# use your version of this file under the terms of the MPL, indicate your
+# decision by deleting the provisions above and replace them with the notice
+# and other provisions required by the GPL or the LGPL. If you do not delete
+# the provisions above, a recipient may use your version of this file under
+# the terms of any one of the MPL, the GPL or the LGPL.
+#
+# ***** END LICENSE BLOCK *****
+
+# A netscape style .mk file for autoconf builds
+
+INCLUDED_AUTOCONF_MK = 1
+USE_AUTOCONF 	= 1
+MOZILLA_CLIENT	= 1
+COMM_BUILD = @COMM_BUILD@
+MOZILLA_SRCDIR = @MOZILLA_SRCDIR@
+MOZILLA_VERSION = @MOZILLA_VERSION@
+THUNDERBIRD_VERSION	= @THUNDERBIRD_VERSION@
+SUNBIRD_VERSION = @SUNBIRD_VERSION@
+SEAMONKEY_VERSION	= @SEAMONKEY_VERSION@
+
+MOZ_BUILD_APP = @MOZ_BUILD_APP@
+MOZ_APP_NAME	= @MOZ_APP_NAME@
+MOZ_APP_DISPLAYNAME = @MOZ_APP_DISPLAYNAME@
+MOZ_APP_VERSION = @MOZ_APP_VERSION@
+
+MOZ_PKG_SPECIAL = @MOZ_PKG_SPECIAL@
+
+prefix		= @prefix@
+exec_prefix	= @exec_prefix@
+bindir		= @bindir@
+includedir	= @includedir@/$(MOZ_APP_NAME)-$(MOZ_APP_VERSION)
+libdir		= @libdir@
+datadir		= @datadir@
+mandir		= @mandir@
+idldir		= $(datadir)/idl/$(MOZ_APP_NAME)-$(MOZ_APP_VERSION)
+
+installdir	= $(libdir)/$(MOZ_APP_NAME)-$(MOZ_APP_VERSION)
+sdkdir		= $(libdir)/$(MOZ_APP_NAME)-devel-$(MOZ_APP_VERSION)
+
+MOZDEPTH	= $(DEPTH)/mozilla
+DIST		= $(MOZDEPTH)/dist
+LIBXUL_SDK      = @LIBXUL_SDK@
+
+ifdef LIBXUL_SDK
+LIBXUL_DIST = $(LIBXUL_SDK)
+else
+LIBXUL_DIST = $(DIST)
+endif
+
+XULRUNNER_STUB_NAME = @XULRUNNER_STUB_NAME@
+
+MOZ_CHROME_FILE_FORMAT	= @MOZ_CHROME_FILE_FORMAT@
+
+MOZ_WIDGET_TOOLKIT	= @MOZ_WIDGET_TOOLKIT@
+MOZ_GFX_TOOLKIT		= @MOZ_GFX_TOOLKIT@
+MOZ_X11			= @MOZ_X11@
+
+MOZ_JS_LIBS		   = @MOZ_JS_LIBS@
+
+MOZ_DEBUG	= @MOZ_DEBUG@
+MOZ_DEBUG_MODULES = @MOZ_DEBUG_MODULES@
+MOZ_PROFILE_MODULES = @MOZ_PROFILE_MODULES@
+MOZ_DEBUG_ENABLE_DEFS		= @MOZ_DEBUG_ENABLE_DEFS@
+MOZ_DEBUG_DISABLE_DEFS	= @MOZ_DEBUG_DISABLE_DEFS@
+MOZ_DEBUG_FLAGS	= @MOZ_DEBUG_FLAGS@
+MOZ_DEBUG_LDFLAGS=@MOZ_DEBUG_LDFLAGS@
+MOZ_DBGRINFO_MODULES	= @MOZ_DBGRINFO_MODULES@
+MOZ_JSDEBUGGER  = @MOZ_JSDEBUGGER@
+MOZ_PERF_METRICS = @MOZ_PERF_METRICS@
+MOZ_LEAKY	= @MOZ_LEAKY@
+MOZ_MEMORY      = @MOZ_MEMORY@
+MOZ_JPROF       = @MOZ_JPROF@
+MOZ_SHARK       = @MOZ_SHARK@
+DEHYDRA_PATH    = @DEHYDRA_PATH@
+
+MOZ_XPCTOOLS    = @MOZ_XPCTOOLS@
+ENABLE_EAZEL_PROFILER=@ENABLE_EAZEL_PROFILER@
+EAZEL_PROFILER_CFLAGS=@EAZEL_PROFILER_CFLAGS@
+EAZEL_PROFILER_LIBS=@EAZEL_PROFILER_LIBS@
+GC_LEAK_DETECTOR = @GC_LEAK_DETECTOR@
+NS_TRACE_MALLOC = @NS_TRACE_MALLOC@
+USE_ELF_DYNSTR_GC = @USE_ELF_DYNSTR_GC@
+USE_PREBINDING = @USE_PREBINDING@
+INCREMENTAL_LINKER = @INCREMENTAL_LINKER@
+MACOSX_DEPLOYMENT_TARGET = @MACOSX_DEPLOYMENT_TARGET@
+MOZ_MAIL_NEWS	= @MOZ_MAIL_NEWS@
+MOZ_CALENDAR	= @MOZ_CALENDAR@
+MOZ_PLAINTEXT_EDITOR_ONLY = @MOZ_PLAINTEXT_EDITOR_ONLY@
+MOZ_COMPOSER = @MOZ_COMPOSER@
+BUILD_STATIC_LIBS = @BUILD_STATIC_LIBS@
+MOZ_ENABLE_LIBXUL = @MOZ_ENABLE_LIBXUL@
+ENABLE_TESTS	= @ENABLE_TESTS@
+IBMBIDI = @IBMBIDI@
+MOZ_UNIVERSALCHARDET = @MOZ_UNIVERSALCHARDET@
+SUNCTL = @SUNCTL@
+ACCESSIBILITY = @ACCESSIBILITY@
+MOZ_VIEW_SOURCE = @MOZ_VIEW_SOURCE@
+MOZ_XPINSTALL = @MOZ_XPINSTALL@
+MOZ_JSLOADER  = @MOZ_JSLOADER@
+MOZ_USE_NATIVE_UCONV = @MOZ_USE_NATIVE_UCONV@
+MOZ_LDAP_XPCOM = @MOZ_LDAP_XPCOM@
+MOZ_LDAP_XPCOM_EXPERIMENTAL = @MOZ_LDAP_XPCOM_EXPERIMENTAL@
+MOZ_BRANDING_DIRECTORY = @MOZ_BRANDING_DIRECTORY@
+XPCOM_USE_LEA = @XPCOM_USE_LEA@
+JS_ULTRASPARC_OPTS = @JS_ULTRASPARC_OPTS@
+JS_STATIC_BUILD = @JS_STATIC_BUILD@
+MOZ_ENABLE_POSTSCRIPT = @MOZ_ENABLE_POSTSCRIPT@
+MOZ_INSTALLER	= @MOZ_INSTALLER@
+MOZ_UPDATER	= @MOZ_UPDATER@
+MOZ_UPDATE_PACKAGING	= @MOZ_UPDATE_PACKAGING@
+MOZ_NO_ACTIVEX_SUPPORT = @MOZ_NO_ACTIVEX_SUPPORT@
+MOZ_ACTIVEX_SCRIPTING_SUPPORT = @MOZ_ACTIVEX_SCRIPTING_SUPPORT@
+MOZ_DISABLE_VISTA_SDK_REQUIREMENTS = @MOZ_DISABLE_VISTA_SDK_REQUIREMENTS@
+MOZ_DISABLE_PARENTAL_CONTROLS = @MOZ_DISABLE_PARENTAL_CONTROLS@
+XPC_IDISPATCH_SUPPORT = @XPC_IDISPATCH_SUPPORT@
+MOZ_SPELLCHECK = @MOZ_SPELLCHECK@
+MOZ_XPFE_COMPONENTS = @MOZ_XPFE_COMPONENTS@
+MOZ_IPCD = @MOZ_IPCD@
+MOZ_PROFILESHARING = @MOZ_PROFILESHARING@
+MOZ_PROFILELOCKING = @MOZ_PROFILELOCKING@
+MOZ_FEEDS = @MOZ_FEEDS@
+MOZ_PLACES = @MOZ_PLACES@
+MOZ_PLACES_BOOKMARKS = @MOZ_PLACES_BOOKMARKS@
+MOZ_STORAGE = @MOZ_STORAGE@
+MOZ_SAFE_BROWSING = @MOZ_SAFE_BROWSING@
+MOZ_URL_CLASSIFIER = @MOZ_URL_CLASSIFIER@
+MOZ_ZIPWRITER = @MOZ_ZIPWRITER@
+MOZ_MORK = @MOZ_MORK@
+MOZ_MORKREADER = @MOZ_MORKREADER@
+MOZ_NO_XPCOM_OBSOLETE = @MOZ_NO_XPCOM_OBSOLETE@
+MOZ_NO_FAST_LOAD = @MOZ_NO_FAST_LOAD@
+NS_PRINTING = @NS_PRINTING@
+MOZ_CRASHREPORTER = @MOZ_CRASHREPORTER@
+MOZ_MOCHITEST = @MOZ_MOCHITEST@
+MOZ_HELP_VIEWER = @MOZ_HELP_VIEWER@
+
+TAR=@TAR@
+
+# The MOZ_UI_LOCALE var is used to build a particular locale. Do *not*
+# use the var to change any binary files. Do *not* use this var unless you
+# write rules for the "clean-locale" and "locale" targets.
+MOZ_UI_LOCALE = @MOZ_UI_LOCALE@
+
+MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS = @MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS@
+MOZ_COMPONENT_NSPR_LIBS=@MOZ_COMPONENT_NSPR_LIBS@
+
+MOZ_FIX_LINK_PATHS=@MOZ_FIX_LINK_PATHS@
+
+XPCOM_FROZEN_LDOPTS=@XPCOM_FROZEN_LDOPTS@
+XPCOM_LIBS=@XPCOM_LIBS@
+MOZ_TIMELINE=@MOZ_TIMELINE@
+
+ENABLE_STRIP	= @ENABLE_STRIP@
+PKG_SKIP_STRIP	= @PKG_SKIP_STRIP@
+
+ClientWallet=1
+CookieManagement=1
+SingleSignon=1
+
+MOZ_OJI		= @MOZ_OJI@
+MOZ_PLUGINS	= @MOZ_PLUGINS@
+
+MOZ_POST_DSO_LIB_COMMAND = @MOZ_POST_DSO_LIB_COMMAND@
+MOZ_POST_PROGRAM_COMMAND = @MOZ_POST_PROGRAM_COMMAND@
+
+MOZ_BUILD_ROOT             = @MOZ_BUILD_ROOT@
+
+MOZ_XUL                    = @MOZ_XUL@
+MOZ_RDF                    = @MOZ_RDF@
+
+MOZ_AUTH_EXTENSION = @MOZ_AUTH_EXTENSION@
+
+MOZ_NATIVE_HUNSPELL = @SYSTEM_HUNSPELL@
+MOZ_HUNSPELL_LIBS = @MOZ_HUNSPELL_LIBS@
+MOZ_HUNSPELL_CFLAGS = @MOZ_HUNSPELL_CFLAGS@
+
+MOZ_NATIVE_ZLIB	= @SYSTEM_ZLIB@
+MOZ_NATIVE_BZ2	= @SYSTEM_BZ2@
+MOZ_NATIVE_JPEG	= @SYSTEM_JPEG@
+MOZ_NATIVE_PNG	= @SYSTEM_PNG@
+MOZ_TREE_CAIRO = @MOZ_TREE_CAIRO@
+
+MOZ_UPDATE_XTERM = @MOZ_UPDATE_XTERM@
+MOZ_PERMISSIONS = @MOZ_PERMISSIONS@
+
+MOZ_PREF_EXTENSIONS = @MOZ_PREF_EXTENSIONS@
+
+MOZ_CAIRO_LIBS = @MOZ_CAIRO_LIBS@
+
+MOZ_ENABLE_GNOMEUI = @MOZ_ENABLE_GNOMEUI@
+MOZ_GNOMEUI_CFLAGS = @MOZ_GNOMEUI_CFLAGS@
+MOZ_GNOMEUI_LIBS = @MOZ_GNOMEUI_LIBS@
+
+MOZ_ENABLE_STARTUP_NOTIFICATION = @MOZ_ENABLE_STARTUP_NOTIFICATION@
+MOZ_STARTUP_NOTIFICATION_CFLAGS = @MOZ_STARTUP_NOTIFICATION_CFLAGS@
+MOZ_STARTUP_NOTIFICATION_LIBS = @MOZ_STARTUP_NOTIFICATION_LIBS@
+
+MOZ_GNOMEVFS_CFLAGS = @MOZ_GNOMEVFS_CFLAGS@
+MOZ_GNOMEVFS_LIBS = @MOZ_GNOMEVFS_LIBS@
+
+MOZ_ENABLE_GCONF = @MOZ_ENABLE_GCONF@
+MOZ_GCONF_CFLAGS = @MOZ_GCONF_CFLAGS@
+MOZ_GCONF_LIBS = @MOZ_GCONF_LIBS@
+
+MOZ_LIBGNOME_CFLAGS = @MOZ_LIBGNOME_CFLAGS@
+MOZ_LIBGNOME_LIBS = @MOZ_LIBGNOME_LIBS@
+
+MOZ_ENABLE_GNOME_COMPONENT = @MOZ_ENABLE_GNOME_COMPONENT@
+
+MOZ_INSURE = @MOZ_INSURE@
+MOZ_INSURIFYING = @MOZ_INSURIFYING@
+MOZ_INSURE_DIRS = @MOZ_INSURE_DIRS@
+MOZ_INSURE_EXCLUDE_DIRS = @MOZ_INSURE_EXCLUDE_DIRS@
+
+MOZ_NATIVE_NSPR = @MOZ_NATIVE_NSPR@
+MOZ_NATIVE_NSS = @MOZ_NATIVE_NSS@
+
+CROSS_COMPILE   = @CROSS_COMPILE@
+
+OS_CPPFLAGS	= @CPPFLAGS@
+OS_CFLAGS	= $(OS_CPPFLAGS) @CFLAGS@
+OS_CXXFLAGS	= $(OS_CPPFLAGS) @CXXFLAGS@
+OS_LDFLAGS	= @LDFLAGS@
+
+OS_COMPILE_CFLAGS = $(OS_CPPFLAGS) @COMPILE_CFLAGS@
+OS_COMPILE_CXXFLAGS = $(OS_CPPFLAGS) @COMPILE_CXXFLAGS@
+
+OS_INCLUDES	= $(NSPR_CFLAGS) $(JPEG_CFLAGS) $(PNG_CFLAGS) $(ZLIB_CFLAGS) $(LCMS_CFLAGS)
+OS_LIBS		= @LIBS@
+ACDEFINES	= @MOZ_DEFINES@
+
+WARNINGS_AS_ERRORS = @WARNINGS_AS_ERRORS@
+
+MOZ_OPTIMIZE	= @MOZ_OPTIMIZE@
+MOZ_OPTIMIZE_FLAGS = @MOZ_OPTIMIZE_FLAGS@
+MOZ_OPTIMIZE_LDFLAGS = @MOZ_OPTIMIZE_LDFLAGS@
+MOZ_OPTIMIZE_SIZE_TWEAK = @MOZ_OPTIMIZE_SIZE_TWEAK@
+
+MOZ_RTTI_FLAGS_ON = @_MOZ_RTTI_FLAGS_ON@
+
+MOZ_PROFILE_GUIDED_OPTIMIZE_DISABLE = @MOZ_PROFILE_GUIDED_OPTIMIZE_DISABLE@
+PROFILE_GEN_CFLAGS = @PROFILE_GEN_CFLAGS@
+PROFILE_GEN_LDFLAGS = @PROFILE_GEN_LDFLAGS@
+PROFILE_USE_CFLAGS = @PROFILE_USE_CFLAGS@
+PROFILE_USE_LDFLAGS = @PROFILE_USE_LDFLAGS@
+
+XCFLAGS		= @XCFLAGS@
+XLDFLAGS	= @XLDFLAGS@
+XLIBS		= @XLIBS@
+
+WIN_TOP_SRC	= @WIN_TOP_SRC@
+CYGWIN_WRAPPER	= @CYGWIN_WRAPPER@
+AS_PERL         = @AS_PERL@
+CYGDRIVE_MOUNT	= @CYGDRIVE_MOUNT@
+AR		= @AR@
+AR_FLAGS	= @AR_FLAGS@
+AR_EXTRACT	= @AR_EXTRACT@
+AR_LIST		= @AR_LIST@
+AR_DELETE	= @AR_DELETE@
+AS		= @AS@
+ASFLAGS		= @ASFLAGS@
+AS_DASH_C_FLAG	= @AS_DASH_C_FLAG@
+LD		= @LD@
+RC		= @RC@
+RCFLAGS		= @RCFLAGS@
+WINDRES		= @WINDRES@
+USE_SHORT_LIBNAME = @USE_SHORT_LIBNAME@
+IMPLIB		= @IMPLIB@
+FILTER		= @FILTER@
+BIN_FLAGS	= @BIN_FLAGS@
+MIDL		= @MIDL@
+MIDL_FLAGS	= @MIDL_FLAGS@
+_MSC_VER	= @_MSC_VER@
+
+DLL_PREFIX	= @DLL_PREFIX@
+LIB_PREFIX	= @LIB_PREFIX@
+OBJ_SUFFIX	= @OBJ_SUFFIX@
+LIB_SUFFIX	= @LIB_SUFFIX@
+DLL_SUFFIX	= @DLL_SUFFIX@
+BIN_SUFFIX	= @BIN_SUFFIX@
+ASM_SUFFIX	= @ASM_SUFFIX@
+IMPORT_LIB_SUFFIX = @IMPORT_LIB_SUFFIX@
+USE_N32		= @USE_N32@
+HAVE_64BIT_OS	= @HAVE_64BIT_OS@
+
+# Temp hack.  It is not my intention to leave this crap in here for ever.
+# Im talking to fur right now to solve the problem without introducing 
+# NS_USE_NATIVE to the build system -ramiro.
+NS_USE_NATIVE = @NS_USE_NATIVE@
+
+CC		    = @CC@
+CXX		    = @CXX@
+
+GNU_AS		= @GNU_AS@
+GNU_LD		= @GNU_LD@
+GNU_CC		= @GNU_CC@
+GNU_CXX		= @GNU_CXX@
+HAVE_GCC3_ABI	= @HAVE_GCC3_ABI@
+INTEL_CC	= @INTEL_CC@
+INTEL_CXX	= @INTEL_CXX@
+
+HOST_CC		= @HOST_CC@
+HOST_CXX	= @HOST_CXX@
+HOST_CFLAGS	= @HOST_CFLAGS@
+HOST_CXXFLAGS	= @HOST_CXXFLAGS@
+HOST_OPTIMIZE_FLAGS = @HOST_OPTIMIZE_FLAGS@
+HOST_NSPR_MDCPUCFG = @HOST_NSPR_MDCPUCFG@
+HOST_AR		= @HOST_AR@
+HOST_AR_FLAGS	= @HOST_AR_FLAGS@
+HOST_LD		= @HOST_LD@
+HOST_RANLIB	= @HOST_RANLIB@
+HOST_BIN_SUFFIX	= @HOST_BIN_SUFFIX@
+
+HOST_LIBIDL_CONFIG = @HOST_LIBIDL_CONFIG@
+HOST_LIBIDL_CFLAGS = @HOST_LIBIDL_CFLAGS@
+HOST_LIBIDL_LIBS   = @HOST_LIBIDL_LIBS@
+
+HOST_OS_ARCH	= @HOST_OS_ARCH@
+host_cpu	= @host_cpu@
+host_vendor	= @host_vendor@
+host_os		= @host_os@
+
+TARGET_NSPR_MDCPUCFG = @TARGET_NSPR_MDCPUCFG@
+TARGET_CPU	= @TARGET_CPU@
+TARGET_VENDOR	= @TARGET_VENDOR@
+TARGET_OS	= @TARGET_OS@
+TARGET_MD_ARCH	= @TARGET_MD_ARCH@
+TARGET_XPCOM_ABI = @TARGET_XPCOM_ABI@
+
+AUTOCONF	= @AUTOCONF@
+PERL		= @PERL@
+PYTHON		= @PYTHON@
+RANLIB		= @RANLIB@
+WHOAMI		= @WHOAMI@
+UNZIP		= @UNZIP@
+ZIP		= @ZIP@
+XARGS		= @XARGS@
+STRIP		= @STRIP@
+DOXYGEN		= @DOXYGEN@
+MAKE		= @MAKE@
+PBBUILD_BIN	= @PBBUILD@
+SDP		= @SDP@
+NSINSTALL_BIN	= @NSINSTALL_BIN@
+
+ifdef MOZ_NATIVE_JPEG
+JPEG_CFLAGS	= @JPEG_CFLAGS@
+JPEG_LIBS	= @JPEG_LIBS@
+JPEG_REQUIRES	=
+else
+JPEG_CFLAGS	= @MOZ_JPEG_CFLAGS@
+JPEG_LIBS	= @MOZ_JPEG_LIBS@
+JPEG_REQUIRES	= jpeg
+endif
+
+ifdef MOZ_NATIVE_ZLIB
+ZLIB_CFLAGS	= @ZLIB_CFLAGS@
+ZLIB_LIBS	= @ZLIB_LIBS@
+ZLIB_REQUIRES	=
+else
+ZLIB_CFLAGS	= @MOZ_ZLIB_CFLAGS@
+ifdef MOZ_ENABLE_LIBXUL
+MOZ_ZLIB_LIBS = @MOZ_ZLIB_LIBS@
+else
+ZLIB_LIBS = @MOZ_ZLIB_LIBS@
+endif
+ZLIB_REQUIRES	= zlib
+endif
+
+ifdef MOZ_NATIVE_BZ2
+BZ2_CFLAGS	= @BZ2_CFLAGS@
+BZ2_LIBS	= @BZ2_LIBS@
+BZ2_REQUIRES	=
+else
+BZ2_CFLAGS	= @MOZ_BZ2_CFLAGS@
+BZ2_LIBS	= @MOZ_BZ2_LIBS@
+BZ2_REQUIRES	= libbz2
+endif
+
+ifdef MOZ_NATIVE_PNG
+PNG_CFLAGS	= @PNG_CFLAGS@
+PNG_LIBS	= @PNG_LIBS@
+PNG_REQUIRES	=
+else
+PNG_CFLAGS	= @MOZ_PNG_CFLAGS@
+PNG_LIBS	= @MOZ_PNG_LIBS@
+PNG_REQUIRES	= png
+endif
+
+MOZ_NATIVE_LCMS	= @MOZ_NATIVE_LCMS@
+LCMS_CFLAGS	= @LCMS_CFLAGS@
+LCMS_LIBS	= @LCMS_LIBS@
+ifdef MOZ_NATIVE_LCMS
+LCMS_REQUIRES	=
+else
+LCMS_REQUIRES	= lcms
+endif
+
+MOZ_NATIVE_SQLITE = @MOZ_NATIVE_SQLITE@
+SQLITE_CFLAGS     = @SQLITE_CFLAGS@
+SQLITE_LIBS       = @SQLITE_LIBS@
+
+NSPR_CONFIG	= @NSPR_CONFIG@
+NSPR_CFLAGS	= @NSPR_CFLAGS@
+NSPR_LIBS	= @NSPR_LIBS@
+
+NSS_CONFIG	= @NSS_CONFIG@
+NSS_CFLAGS	= @NSS_CFLAGS@
+NSS_LIBS	= @NSS_LIBS@
+NSS_DEP_LIBS	= @NSS_DEP_LIBS@
+
+LDAP_CFLAGS	= @LDAP_CFLAGS@
+LDAP_LIBS	= @LDAP_LIBS@
+XPCOM_GLUE_LDOPTS = @XPCOM_GLUE_LDOPTS@
+XPCOM_STANDALONE_GLUE_LDOPTS = @XPCOM_STANDALONE_GLUE_LDOPTS@
+MOZ_XPCOM_OBSOLETE_LIBS = @MOZ_XPCOM_OBSOLETE_LIBS@
+
+USE_DEPENDENT_LIBS = @USE_DEPENDENT_LIBS@
+
+# UNIX98 iconv support
+LIBICONV = @LIBICONV@
+
+# MKSHLIB_FORCE_ALL is used to force the linker to include all object
+# files present in an archive. MKSHLIB_UNFORCE_ALL reverts the linker
+# to normal behavior. Makefile's that create shared libraries out of
+# archives use these flags to force in all of the .o files in the
+# archives into the shared library.
+WRAP_MALLOC_LIB         = @WRAP_MALLOC_LIB@
+WRAP_MALLOC_CFLAGS      = @WRAP_MALLOC_CFLAGS@
+DSO_CFLAGS              = @DSO_CFLAGS@
+DSO_PIC_CFLAGS          = @DSO_PIC_CFLAGS@
+MKSHLIB                 = @MKSHLIB@
+MKCSHLIB                = @MKCSHLIB@
+MKSHLIB_FORCE_ALL       = @MKSHLIB_FORCE_ALL@
+MKSHLIB_UNFORCE_ALL     = @MKSHLIB_UNFORCE_ALL@
+DSO_LDOPTS              = @DSO_LDOPTS@
+DLL_SUFFIX              = @DLL_SUFFIX@
+
+NO_LD_ARCHIVE_FLAGS     = @NO_LD_ARCHIVE_FLAGS@
+
+GTK_CONFIG	= @GTK_CONFIG@
+TK_CFLAGS	= @TK_CFLAGS@
+TK_LIBS		= @TK_LIBS@
+
+MOZ_TOOLKIT_REGISTRY_CFLAGS = \
+	$(TK_CFLAGS)
+
+CAIRO_FT_CFLAGS		= @CAIRO_FT_CFLAGS@
+
+MOZ_ENABLE_CAIRO_FT	= @MOZ_ENABLE_CAIRO_FT@
+MOZ_ENABLE_GLITZ        = @MOZ_ENABLE_GLITZ@
+MOZ_ENABLE_GTK2		= @MOZ_ENABLE_GTK2@
+MOZ_ENABLE_PHOTON	= @MOZ_ENABLE_PHOTON@
+MOZ_ENABLE_COCOA	= @MOZ_ENABLE_COCOA@
+MOZ_ENABLE_XREMOTE	= @MOZ_ENABLE_XREMOTE@
+
+MOZ_GTK2_CFLAGS		= @MOZ_GTK2_CFLAGS@
+MOZ_GTK2_LIBS		= @MOZ_GTK2_LIBS@
+
+MOZ_DBUS_GLIB_CFLAGS    = @MOZ_DBUS_GLIB_CFLAGS@
+MOZ_DBUS_GLIB_LIBS      = @MOZ_DBUS_GLIB_LIBS@
+MOZ_ENABLE_DBUS         = @MOZ_ENABLE_DBUS@
+
+MOZ_GTHREAD_CFLAGS      = @MOZ_GTHREAD_CFLAGS@
+MOZ_GTHREAD_LIBS        = @MOZ_GTHREAD_LIBS@
+
+FT2_CFLAGS             = @FT2_CFLAGS@
+FT2_LIBS               = @FT2_LIBS@
+
+MOZ_XFT_CFLAGS		= @MOZ_XFT_CFLAGS@
+MOZ_XFT_LIBS		= @MOZ_XFT_LIBS@
+MOZ_PANGO_CFLAGS        = @MOZ_PANGO_CFLAGS@
+MOZ_PANGO_LIBS          = @MOZ_PANGO_LIBS@
+
+MOZ_XIE_LIBS		= @MOZ_XIE_LIBS@
+XT_LIBS			= @XT_LIBS@
+
+GLIB_CFLAGS	= @GLIB_CFLAGS@
+GLIB_LIBS	= @GLIB_LIBS@
+GLIB_GMODULE_LIBS	= @GLIB_GMODULE_LIBS@
+LIBIDL_CFLAGS = @LIBIDL_CFLAGS@
+LIBIDL_LIBS = @LIBIDL_LIBS@
+STATIC_LIBIDL = @STATIC_LIBIDL@
+
+MOZ_NATIVE_MAKEDEPEND	= @SYSTEM_MAKEDEPEND@
+
+# Used for LD_LIBRARY_PATH
+LIBS_PATH       = @LIBS_PATH@
+
+MOZ_AUTO_DEPS	= @MOZ_AUTO_DEPS@
+COMPILER_DEPEND = @COMPILER_DEPEND@
+MDDEPDIR        := @MDDEPDIR@
+
+MOZ_DEMANGLE_SYMBOLS = @MOZ_DEMANGLE_SYMBOLS@
+
+# XXX - these need to be cleaned up and have real checks added -cls
+CM_BLDTYPE=dbg
+AWT_11=1
+MOZ_BITS=32
+OS_TARGET=@OS_TARGET@
+OS_ARCH=@OS_ARCH@
+OS_RELEASE=@OS_RELEASE@
+OS_TEST=@OS_TEST@
+
+TARGET_DEVICE = @TARGET_DEVICE@
+
+# For AIX build
+AIX_OBJMODEL = @AIX_OBJMODEL@
+
+# For OS/2 build
+MOZ_OS2_TOOLS = @MOZ_OS2_TOOLS@
+MOZ_OS2_USE_DECLSPEC = @MOZ_OS2_USE_DECLSPEC@
+MOZ_OS2_HIGH_MEMORY = @MOZ_OS2_HIGH_MEMORY@
+
+HAVE_XIE=@HAVE_XIE@
+
+MOZ_MOVEMAIL=@MOZ_MOVEMAIL@
+MOZ_PSM=@MOZ_PSM@
+
+# Gssapi (krb5) libraries and headers for the Negotiate auth method
+GSSAPI_INCLUDES = @GSSAPI_INCLUDES@
+USE_GSSAPI	= @USE_GSSAPI@
+
+MOZILLA_OFFICIAL = @MOZILLA_OFFICIAL@
+BUILD_OFFICIAL = @BUILD_OFFICIAL@
+MOZ_MILESTONE_RELEASE = @MOZ_MILESTONE_RELEASE@
+
+# Win32 options
+MOZ_PROFILE	= @MOZ_PROFILE@
+MOZ_BROWSE_INFO	= @MOZ_BROWSE_INFO@
+MOZ_TOOLS_DIR	= @MOZ_TOOLS_DIR@
+MOZ_DEBUG_SYMBOLS = @MOZ_DEBUG_SYMBOLS@
+MOZ_QUANTIFY	= @MOZ_QUANTIFY@
+MSMANIFEST_TOOL = @MSMANIFEST_TOOL@
+WIN32_REDIST_DIR = @WIN32_REDIST_DIR@
+WIN32_CRT_SRC_DIR = @WIN32_CRT_SRC_DIR@
+WIN32_CUSTOM_CRT_DIR = @WIN32_CUSTOM_CRT_DIR@
+# These are for custom CRT building
+ifdef MOZ_MEMORY
+ifneq (,$(WIN32_CRT_SRC_DIR)$(WIN32_CUSTOM_CRT_DIR))
+export LIB = @MOZ_LIB@
+export PATH = @MOZ_PATH@
+DLLFLAGS = @DLLFLAGS@
+endif
+endif
+
+# python options.
+MOZ_PYTHON_EXTENSIONS = @MOZ_PYTHON_EXTENSIONS@
+MOZ_PYTHON = @MOZ_PYTHON@
+MOZ_PYTHON_PREFIX = @MOZ_PYTHON_PREFIX@
+MOZ_PYTHON_INCLUDES = @MOZ_PYTHON_INCLUDES@
+MOZ_PYTHON_LIBS = @MOZ_PYTHON_LIBS@
+MOZ_PYTHON_DEBUG_SUFFIX = @MOZ_PYTHON_DEBUG_SUFFIX@
+MOZ_PYTHON_DLL_SUFFIX = @MOZ_PYTHON_DLL_SUFFIX@
+MOZ_PYTHON_VER_DOTTED = @MOZ_PYTHON_VER_DOTTED@
+MOZ_PYTHON_VER = @MOZ_PYTHON_VER@
+
+# Codesighs tools option, enables win32 mapfiles.
+MOZ_MAPINFO	= @MOZ_MAPINFO@
+
+MOZ_XUL_APP	= @MOZ_XUL_APP@
+MOZ_THUNDERBIRD = @MOZ_THUNDERBIRD@
+MOZ_STATIC_MAIL_BUILD = @MOZ_STATIC_MAIL_BUILD@
+MOZ_SUNBIRD	= @MOZ_SUNBIRD@
+MOZ_SUITE	= @MOZ_SUITE@
+WINCE		= @WINCE@
+
+MOZ_DISTRIBUTION_ID = @MOZ_DISTRIBUTION_ID@
+
+MACOS_SDK_DIR	= @MACOS_SDK_DIR@
+NEXT_ROOT	= @NEXT_ROOT@
+GCC_VERSION	= @GCC_VERSION@
+XCODEBUILD_VERSION= @XCODEBUILD_VERSION@
+HAS_XCODE_2_1	= @HAS_XCODE_2_1@
+UNIVERSAL_BINARY= @UNIVERSAL_BINARY@
+HAVE_DTRACE= @HAVE_DTRACE@
+
+VISIBILITY_FLAGS = @VISIBILITY_FLAGS@
+WRAP_SYSTEM_INCLUDES = @WRAP_SYSTEM_INCLUDES@
+
+MOZ_V1_STRING_ABI = @MOZ_V1_STRING_ABI@
+
+MOZ_EMBEDDING_LEVEL_DEFAULT = @MOZ_EMBEDDING_LEVEL_DEFAULT@
+MOZ_EMBEDDING_LEVEL_BASIC = @MOZ_EMBEDDING_LEVEL_BASIC@
+MOZ_EMBEDDING_LEVEL_MINIMAL = @MOZ_EMBEDDING_LEVEL_MINIMAL@
new file mode 100644
--- /dev/null
+++ b/config/config.mk
@@ -0,0 +1,890 @@
+#
+# ***** BEGIN LICENSE BLOCK *****
+# Version: MPL 1.1/GPL 2.0/LGPL 2.1
+#
+# The contents of this file are subject to the Mozilla Public License Version
+# 1.1 (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+# http://www.mozilla.org/MPL/
+#
+# Software distributed under the License is distributed on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+# for the specific language governing rights and limitations under the
+# License.
+#
+# The Original Code is mozilla.org code.
+#
+# The Initial Developer of the Original Code is
+# Netscape Communications Corporation.
+# Portions created by the Initial Developer are Copyright (C) 1998
+# the Initial Developer. All Rights Reserved.
+#
+# Contributor(s):
+#   Benjamin Smedberg <benjamin@smedbergs.us>
+#
+# Alternatively, the contents of this file may be used under the terms of
+# either of the GNU General Public License Version 2 or later (the "GPL"),
+# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+# in which case the provisions of the GPL or the LGPL are applicable instead
+# of those above. If you wish to allow use of your version of this file only
+# under the terms of either the GPL or the LGPL, and not to allow others to
+# use your version of this file under the terms of the MPL, indicate your
+# decision by deleting the provisions above and replace them with the notice
+# and other provisions required by the GPL or the LGPL. If you do not delete
+# the provisions above, a recipient may use your version of this file under
+# the terms of any one of the MPL, the GPL or the LGPL.
+#
+# ***** END LICENSE BLOCK *****
+
+#
+# config.mk
+#
+# Determines the platform and builds the macros needed to load the
+# appropriate platform-specific .mk file, then defines all (most?)
+# of the generic macros.
+#
+
+# Define an include-at-most-once flag
+INCLUDED_CONFIG_MK = 1
+
+EXIT_ON_ERROR = set -e; # Shell loops continue past errors without this.
+
+ifndef topsrcdir
+topsrcdir	= $(DEPTH)
+endif
+
+ifndef INCLUDED_AUTOCONF_MK
+include $(DEPTH)/config/autoconf.mk
+endif
+ifndef INCLUDED_INSURE_MK
+ifdef MOZ_INSURIFYING
+include $(MOZILLA_SRCDIR)/config/insure.mk
+endif
+endif
+
+COMMA = ,
+
+# Sanity check some variables
+CHECK_VARS := \
+ XPI_NAME \
+ LIBRARY_NAME \
+ MODULE \
+ DEPTH \
+ SHORT_LIBNAME \
+ XPI_PKGNAME \
+ INSTALL_EXTENSION_ID \
+ $(NULL)
+
+# checks for internal spaces or trailing spaces in the variable
+# named by $x
+check-variable = $(if $(filter-out 0 1,$(words $($(x))z)),$(error Spaces are not allowed in $(x)))
+
+$(foreach x,$(CHECK_VARS),$(check-variable))
+
+# FINAL_TARGET specifies the location into which we copy end-user-shipped
+# build products (typelibs, components, chrome).
+#
+# It will usually be the well-loved $(DIST)/bin, today, but can also be an
+# XPI-contents staging directory for ambitious and right-thinking extensions.
+FINAL_TARGET = $(if $(XPI_NAME),$(DIST)/xpi-stage/$(XPI_NAME),$(DIST)/bin)
+
+# MAKE_JARS_TARGET is a staging area for make-jars.pl.  When packaging in
+# the jar format, make-jars leaves behind a directory structure that's not
+# needed in $(FINAL_TARGET).  For both, flat, and symlink, the directory
+# structure contains the chrome, so leave it in $(FINAL_TARGET).
+ifeq (jar,$(MOZ_CHROME_FILE_FORMAT))
+MAKE_JARS_TARGET = $(if $(XPI_NAME),$(FINAL_TARGET).stage,$(DIST)/chrome-stage)
+else
+MAKE_JARS_TARGET = $(FINAL_TARGET)
+endif
+
+#
+# The VERSION_NUMBER is suffixed onto the end of the DLLs we ship.
+# Since the longest of these is 5 characters without the suffix,
+# be sure to not set VERSION_NUMBER to anything longer than 3 
+# characters for Win16's sake.
+#
+VERSION_NUMBER		= 50
+
+ifeq ($(HOST_OS_ARCH),WINNT)
+win_srcdir      := $(subst $(topsrcdir),$(WIN_TOP_SRC),$(srcdir))
+BUILD_TOOLS     = $(WIN_TOP_SRC)/mozilla/build/unix
+else
+win_srcdir      := $(srcdir)
+BUILD_TOOLS     = $(MOZILLA_SRCDIR)/build/unix
+endif
+
+CONFIG_TOOLS	= $(MOZ_BUILD_ROOT)/mozilla/config
+AUTOCONF_TOOLS	= $(MOZILLA_SRCDIR)/build/autoconf
+
+ifeq ($(OS_ARCH),QNX)
+ifeq ($(OS_TARGET),NTO)
+LD		:= qcc -Vgcc_ntox86 -nostdlib
+else
+LD		:= $(CC)
+endif
+endif
+ifeq ($(OS_ARCH),BeOS)
+BEOS_ADDON_WORKAROUND	= 1
+endif
+
+#
+# Strip off the excessively long version numbers on these platforms,
+# but save the version to allow multiple versions of the same base
+# platform to be built in the same tree.
+#
+ifneq (,$(filter FreeBSD HP-UX IRIX Linux NetBSD OpenBSD OSF1 SunOS,$(OS_ARCH)))
+OS_RELEASE	:= $(basename $(OS_RELEASE))
+
+# Allow the user to ignore the OS_VERSION, which is usually irrelevant.
+ifdef WANT_MOZILLA_CONFIG_OS_VERSION
+OS_VERS		:= $(suffix $(OS_RELEASE))
+OS_VERSION	:= $(shell echo $(OS_VERS) | sed 's/-.*//')
+endif
+
+endif
+
+OS_CONFIG	:= $(OS_ARCH)$(OS_RELEASE)
+
+FINAL_LINK_LIBS = $(MOZDEPTH)/config/final-link-libs
+FINAL_LINK_COMPS = $(MOZDEPTH)/config/final-link-comps
+FINAL_LINK_COMP_NAMES = $(MOZDEPTH)/config/final-link-comp-names
+
+MOZ_UNICHARUTIL_LIBS = $(LIBXUL_DIST)/lib/$(LIB_PREFIX)unicharutil_s.$(LIB_SUFFIX)
+MOZ_WIDGET_SUPPORT_LIBS    = $(DIST)/lib/$(LIB_PREFIX)widgetsupport_s.$(LIB_SUFFIX)
+
+# determine debug-related options
+_DEBUG_CFLAGS :=
+_DEBUG_LDFLAGS :=
+
+ifndef MOZ_DEBUG
+  # global debugging is disabled 
+  # check if it was explicitly enabled for this module
+  ifneq (, $(findstring $(MODULE), $(MOZ_DEBUG_MODULES)))
+    MOZ_DEBUG:=1
+  endif
+else
+  # global debugging is enabled
+  # check if it was explicitly disabled for this module
+  ifneq (, $(findstring ^$(MODULE), $(MOZ_DEBUG_MODULES)))
+    MOZ_DEBUG:=
+  endif
+endif
+
+ifdef MOZ_DEBUG
+  _DEBUG_CFLAGS += $(MOZ_DEBUG_ENABLE_DEFS)
+  XULPPFLAGS += $(MOZ_DEBUG_ENABLE_DEFS)
+else
+  _DEBUG_CFLAGS += $(MOZ_DEBUG_DISABLE_DEFS)
+  XULPPFLAGS += $(MOZ_DEBUG_DISABLE_DEFS)
+endif
+
+# determine if -g should be passed to the compiler, based on
+# the current module, and the value of MOZ_DBGRINFO_MODULES
+
+ifdef MOZ_DEBUG
+  MOZ_DBGRINFO_MODULES += ALL_MODULES
+  pattern := ALL_MODULES ^ALL_MODULES
+else
+  MOZ_DBGRINFO_MODULES += ^ALL_MODULES
+  pattern := ALL_MODULES ^ALL_MODULES
+endif
+
+ifdef MODULE
+  # our current Makefile specifies a module name - add it to our pattern
+  pattern += $(MODULE) ^$(MODULE)
+endif
+
+# start by finding the first relevant module name 
+# (remember that the order of the module names in MOZ_DBGRINFO_MODULES 
+# is reversed from the order the user specified to configure - 
+# this allows the user to put general names at the beginning
+# of the list, and to override them with explicit module names later 
+# in the list)
+
+first_match:=$(firstword $(filter $(pattern), $(MOZ_DBGRINFO_MODULES)))
+
+ifeq ($(first_match), $(MODULE))
+  # the user specified explicitly that 
+  # this module should be compiled with -g
+  _DEBUG_CFLAGS += $(MOZ_DEBUG_FLAGS)
+  _DEBUG_LDFLAGS += $(MOZ_DEBUG_LDFLAGS)
+else
+  ifeq ($(first_match), ^$(MODULE))
+    # the user specified explicitly that this module 
+    # should not be compiled with -g (nothing to do)
+  else
+    ifeq ($(first_match), ALL_MODULES)
+      # the user didn't mention this module explicitly, 
+      # but wanted all modules to be compiled with -g
+      _DEBUG_CFLAGS += $(MOZ_DEBUG_FLAGS)
+      _DEBUG_LDFLAGS += $(MOZ_DEBUG_LDFLAGS)      
+    else
+      ifeq ($(first_match), ^ALL_MODULES)
+        # the user didn't mention this module explicitly, 
+        # but wanted all modules to be compiled without -g (nothing to do)
+      endif
+    endif
+  endif
+endif
+
+
+# append debug flags 
+# (these might have been above when processing MOZ_DBGRINFO_MODULES)
+OS_CFLAGS += $(_DEBUG_CFLAGS)
+OS_CXXFLAGS += $(_DEBUG_CFLAGS)
+OS_LDFLAGS += $(_DEBUG_LDFLAGS)
+
+# MOZ_PROFILE equivs for win32
+ifeq ($(OS_ARCH)_$(GNU_CC),WINNT_)
+ifdef MOZ_DEBUG
+ifneq (,$(MOZ_BROWSE_INFO)$(MOZ_BSCFILE))
+OS_CFLAGS += -FR
+OS_CXXFLAGS += -FR
+endif
+else # ! MOZ_DEBUG
+
+# MOZ_DEBUG_SYMBOLS generates debug symbols in separate PDB files.
+# Used for generating an optimized build with debugging symbols.
+# Used in the Windows nightlies to generate symbols for crash reporting.
+ifdef MOZ_DEBUG_SYMBOLS
+OS_CXXFLAGS += -Zi -UDEBUG -DNDEBUG
+OS_CFLAGS += -Zi -UDEBUG -DNDEBUG
+OS_LDFLAGS += -DEBUG -OPT:REF -OPT:nowin98
+endif
+
+ifdef MOZ_QUANTIFY
+# -FIXED:NO is needed for Quantify to work, but it increases the size
+# of executables, so only use it if building for Quantify.
+WIN32_EXE_LDFLAGS += -FIXED:NO
+
+# We need -OPT:NOICF to prevent identical methods from being merged together.
+# Otherwise, Quantify doesn't know which method was actually called when it's
+# showing you the profile.
+OS_LDFLAGS += -OPT:NOICF
+endif
+
+#
+# Handle trace-malloc in optimized builds.
+# No opt to give sane callstacks.
+#
+ifdef NS_TRACE_MALLOC
+MOZ_OPTIMIZE_FLAGS=-Zi -Od -UDEBUG -DNDEBUG
+OS_LDFLAGS = -DEBUG -PDB:NONE -OPT:REF -OPT:nowin98
+endif # NS_TRACE_MALLOC
+
+endif # MOZ_DEBUG
+endif # WINNT && !GNU_CC
+
+#
+# Build using PIC by default
+# Do not use PIC if not building a shared lib (see exceptions below)
+#
+
+ifndef BUILD_STATIC_LIBS
+_ENABLE_PIC=1
+endif
+ifneq (,$(FORCE_SHARED_LIB)$(FORCE_USE_PIC))
+_ENABLE_PIC=1
+endif
+
+# In Firefox, all components are linked into either libxul or the static
+# meta-component, and should be compiled with PIC.
+ifdef MOZ_META_COMPONENT
+_ENABLE_PIC=1
+endif
+
+# If module is going to be merged into the nsStaticModule, 
+# make sure that the entry points are translated and 
+# the module is built static.
+
+ifdef IS_COMPONENT
+ifdef EXPORT_LIBRARY
+ifneq (,$(BUILD_STATIC_LIBS))
+ifdef MODULE_NAME
+DEFINES += -DXPCOM_TRANSLATE_NSGM_ENTRY_POINT=1
+FORCE_STATIC_LIB=1
+endif
+endif
+endif
+endif
+
+# Determine if module being compiled is destined 
+# to be merged into libxul
+
+ifdef MOZ_ENABLE_LIBXUL
+ifdef LIBXUL_LIBRARY
+ifdef IS_COMPONENT
+ifdef MODULE_NAME
+DEFINES += -DXPCOM_TRANSLATE_NSGM_ENTRY_POINT=1
+else
+$(error Component makefile does not specify MODULE_NAME.)
+endif
+endif
+FORCE_STATIC_LIB=1
+_ENABLE_PIC=1
+SHORT_LIBNAME=
+endif
+endif
+
+# If we are building this component into an extension/xulapp, it cannot be
+# statically linked. In the future we may want to add a xulapp meta-component
+# build option.
+
+ifdef XPI_NAME
+_ENABLE_PIC=1
+ifdef IS_COMPONENT
+EXPORT_LIBRARY=
+FORCE_STATIC_LIB=
+FORCE_SHARED_LIB=1
+endif
+endif
+
+#
+# Disable PIC if necessary
+#
+
+ifndef _ENABLE_PIC
+DSO_CFLAGS=
+ifeq ($(OS_ARCH)_$(HAVE_GCC3_ABI),Darwin_1)
+DSO_PIC_CFLAGS=-mdynamic-no-pic
+else
+DSO_PIC_CFLAGS=
+endif
+endif
+
+# This comes from configure
+ifdef MOZ_PROFILE_GUIDED_OPTIMIZE_DISABLE
+NO_PROFILE_GUIDED_OPTIMIZE = 1
+endif
+
+# Enable profile-based feedback
+ifndef NO_PROFILE_GUIDED_OPTIMIZE
+ifdef MOZ_PROFILE_GENERATE
+# No sense in profiling tools
+ifndef INTERNAL_TOOLS
+OS_CFLAGS += $(PROFILE_GEN_CFLAGS)
+OS_CXXFLAGS += $(PROFILE_GEN_CFLAGS)
+OS_LDFLAGS += $(PROFILE_GEN_LDFLAGS)
+ifeq (WINNT,$(OS_ARCH))
+AR_FLAGS += -LTCG
+endif
+endif # INTERNAL_TOOLS
+endif # MOZ_PROFILE_GENERATE
+
+ifdef MOZ_PROFILE_USE
+ifndef INTERNAL_TOOLS
+OS_CFLAGS += $(PROFILE_USE_CFLAGS)
+OS_CXXFLAGS += $(PROFILE_USE_CFLAGS)
+OS_LDFLAGS += $(PROFILE_USE_LDFLAGS)
+ifeq (WINNT,$(OS_ARCH))
+AR_FLAGS += -LTCG
+endif
+endif # INTERNAL_TOOLS
+endif # MOZ_PROFILE_USE
+endif # NO_PROFILE_GUIDED_OPTIMIZE
+
+
+# Does the makefile specifies the internal XPCOM API linkage?
+ifneq (,$(MOZILLA_INTERNAL_API)$(LIBXUL_LIBRARY))
+DEFINES += -DMOZILLA_INTERNAL_API
+endif
+
+# Force XPCOM/widget/gfx methods to be _declspec(dllexport) when we're
+# building libxul libraries
+ifdef MOZ_ENABLE_LIBXUL
+ifdef LIBXUL_LIBRARY
+DEFINES += \
+		-D_IMPL_NS_COM \
+		-DEXPORT_XPT_API \
+		-DEXPORT_XPTC_API \
+		-D_IMPL_NS_COM_OBSOLETE \
+		-D_IMPL_NS_GFX \
+		-D_IMPL_NS_WIDGET \
+		-DIMPL_XREAPI \
+		-DIMPL_NS_NET \
+		-DIMPL_THEBES \
+		$(NULL)
+
+ifndef MOZ_NATIVE_ZLIB
+DEFINES += -DZLIB_INTERNAL
+endif
+endif
+endif
+
+# Force _all_ exported methods to be |_declspec(dllexport)| when we're
+# building them into the executable.
+
+ifeq (,$(filter-out WINNT WINCE OS2, $(OS_ARCH)))
+ifdef BUILD_STATIC_LIBS
+DEFINES += \
+        -D_IMPL_NS_GFX \
+        -D_IMPL_NS_MSG_BASE \
+        -D_IMPL_NS_WIDGET \
+        $(NULL)
+endif
+endif
+
+# Flags passed to make-jars.pl
+
+MAKE_JARS_FLAGS = \
+	-s $(srcdir) -t $(topsrcdir) -z $(ZIP) -p $(MOZILLA_DIR)/config/preprocessor.pl \
+	-f $(MOZ_CHROME_FILE_FORMAT) \
+	$(NULL)
+
+ifdef NO_JAR_AUTO_REG
+MAKE_JARS_FLAGS += -a
+endif
+
+ifdef USE_EXTENSION_MANIFEST
+MAKE_JARS_FLAGS += -e
+endif
+
+ifeq ($(OS_TARGET),WIN95)
+MAKE_JARS_FLAGS += -l
+endif
+
+ifneq (,$(filter gtk2,$(MOZ_WIDGET_TOOLKIT)))
+MAKE_JARS_FLAGS += -x
+endif
+
+ifdef CROSS_COMPILE
+MAKE_JARS_FLAGS += -o $(OS_ARCH)
+endif
+
+TAR_CREATE_FLAGS = -cvhf
+
+ifeq ($(OS_ARCH),BSD_OS)
+TAR_CREATE_FLAGS = -cvLf
+endif
+
+ifeq ($(OS_ARCH),OS2)
+TAR_CREATE_FLAGS = -cvf
+endif
+
+#
+# Personal makefile customizations go in these optional make include files.
+#
+MY_CONFIG	:= $(DEPTH)/config/myconfig.mk
+MY_RULES	:= $(DEPTH)/config/myrules.mk
+
+#
+# Default command macros; can be overridden in <arch>.mk.
+#
+CCC		= $(CXX)
+NFSPWD		= $(CONFIG_TOOLS)/nfspwd
+PURIFY		= purify $(PURIFYOPTIONS)
+QUANTIFY	= quantify $(QUANTIFYOPTIONS)
+ifdef CROSS_COMPILE
+XPIDL_COMPILE 	= $(CYGWIN_WRAPPER) $(LIBXUL_DIST)/host/bin/host_xpidl$(HOST_BIN_SUFFIX)
+XPIDL_LINK	= $(CYGWIN_WRAPPER) $(LIBXUL_DIST)/host/bin/host_xpt_link$(HOST_BIN_SUFFIX)
+else
+XPIDL_COMPILE 	= $(CYGWIN_WRAPPER) $(LIBXUL_DIST)/bin/xpidl$(BIN_SUFFIX)
+XPIDL_LINK	= $(CYGWIN_WRAPPER) $(LIBXUL_DIST)/bin/xpt_link$(BIN_SUFFIX)
+endif
+
+REQ_INCLUDES	= -I$(srcdir) -I. $(foreach d,$(REQUIRES),-I$(DIST)/include/$d) -I$(DIST)/include 
+ifdef LIBXUL_SDK
+REQ_INCLUDES_SDK = $(foreach d,$(REQUIRES),-I$(LIBXUL_SDK)/include/$d) -I$(LIBXUL_SDK)/include
+endif
+
+INCLUDES	= $(LOCAL_INCLUDES) $(REQ_INCLUDES) $(REQ_INCLUDES_SDK) -I$(PUBLIC) $(OS_INCLUDES)
+
+ifndef MOZILLA_INTERNAL_API
+INCLUDES	+= -I$(LIBXUL_DIST)/sdk/include
+endif
+
+# The entire tree should be subject to static analysis using the XPCOM
+# script. Additional scripts may be added by specific subdirectories.
+
+DEHYDRA_SCRIPT = $(MOZILLA_SRCDIR)/xpcom/analysis/static-checking.js
+
+DEHYDRA_MODULES = \
+  $(MOZILLA_SRCDIR)/xpcom/analysis/final.js \
+  $(NULL)
+
+TREEHYDRA_MODULES = \
+  $(MOZILLA_SRCDIR)/xpcom/analysis/outparams.js \
+  $(MOZILLA_SRCDIR)/xpcom/analysis/stack.js \
+  $(NULL)
+
+DEHYDRA_ARGS = \
+  --topsrcdir=$(topsrcdir) \
+  --objdir=$(DEPTH) \
+  --dehydra-modules=$(subst $(NULL) ,$(COMMA),$(strip $(DEHYDRA_MODULES))) \
+  --treehydra-modules=$(subst $(NULL) ,$(COMMA),$(strip $(TREEHYDRA_MODULES))) \
+  $(NULL)
+
+DEHYDRA_FLAGS = -fplugin=$(DEHYDRA_PATH) -fplugin-arg="$(DEHYDRA_SCRIPT) $(DEHYDRA_ARGS)"
+
+ifdef DEHYDRA_PATH
+OS_CXXFLAGS += $(DEHYDRA_FLAGS)
+endif
+
+CFLAGS		= $(OS_CFLAGS)
+CXXFLAGS	= $(OS_CXXFLAGS)
+LDFLAGS		= $(OS_LDFLAGS) $(MOZ_FIX_LINK_PATHS)
+
+# Allow each module to override the *default* optimization settings
+# by setting MODULE_OPTIMIZE_FLAGS if the developer has not given
+# arguments to --enable-optimize
+ifdef MOZ_OPTIMIZE
+ifeq (1,$(MOZ_OPTIMIZE))
+ifdef MODULE_OPTIMIZE_FLAGS
+CFLAGS		+= $(MODULE_OPTIMIZE_FLAGS)
+CXXFLAGS	+= $(MODULE_OPTIMIZE_FLAGS)
+else
+CFLAGS		+= $(MOZ_OPTIMIZE_FLAGS)
+CXXFLAGS	+= $(MOZ_OPTIMIZE_FLAGS)
+endif # MODULE_OPTIMIZE_FLAGS
+else
+CFLAGS		+= $(MOZ_OPTIMIZE_FLAGS)
+CXXFLAGS	+= $(MOZ_OPTIMIZE_FLAGS)
+endif # MOZ_OPTIMIZE == 1
+LDFLAGS		+= $(MOZ_OPTIMIZE_LDFLAGS)
+endif # MOZ_OPTIMIZE
+
+ifdef CROSS_COMPILE
+HOST_CFLAGS	+= $(HOST_OPTIMIZE_FLAGS)
+else
+ifdef MOZ_OPTIMIZE
+ifeq (1,$(MOZ_OPTIMIZE))
+ifdef MODULE_OPTIMIZE_FLAGS
+HOST_CFLAGS	+= $(MODULE_OPTIMIZE_FLAGS)
+else
+HOST_CFLAGS	+= $(MOZ_OPTIMIZE_FLAGS)
+endif # MODULE_OPTIMIZE_FLAGS
+else
+HOST_CFLAGS	+= $(MOZ_OPTIMIZE_FLAGS)
+endif # MOZ_OPTIMIZE == 1
+endif # MOZ_OPTIMIZE
+endif # CROSS_COMPILE
+
+ifeq ($(MOZ_OS2_TOOLS),VACPP)
+ifdef USE_STATIC_LIBS
+RTL_FLAGS += -Gd-
+else # !USE_STATIC_LIBS
+RTL_FLAGS += -Gd+
+endif
+endif
+
+
+ifeq ($(OS_ARCH)_$(GNU_CC),WINNT_)
+#// Currently, unless USE_STATIC_LIBS is defined, the multithreaded
+#// DLL version of the RTL is used...
+#//
+#//------------------------------------------------------------------------
+ifdef USE_STATIC_LIBS
+RTL_FLAGS=-MT          # Statically linked multithreaded RTL
+ifneq (,$(MOZ_DEBUG)$(NS_TRACE_MALLOC))
+ifndef MOZ_NO_DEBUG_RTL
+RTL_FLAGS=-MTd         # Statically linked multithreaded MSVC4.0 debug RTL
+endif
+endif # MOZ_DEBUG || NS_TRACE_MALLOC
+
+else # !USE_STATIC_LIBS
+
+RTL_FLAGS=-MD          # Dynamically linked, multithreaded RTL
+ifneq (,$(MOZ_DEBUG)$(NS_TRACE_MALLOC))
+ifndef MOZ_NO_DEBUG_RTL
+RTL_FLAGS=-MDd         # Dynamically linked, multithreaded MSVC4.0 debug RTL
+endif 
+endif # MOZ_DEBUG || NS_TRACE_MALLOC
+endif # USE_STATIC_LIBS
+endif # WINNT && !GNU_CC
+
+ifeq ($(OS_ARCH),Darwin)
+# Darwin doesn't cross-compile, so just set both types of flags here.
+HOST_CMFLAGS += -fobjc-exceptions
+HOST_CMMFLAGS += -fobjc-exceptions
+OS_COMPILE_CMFLAGS += -fobjc-exceptions
+OS_COMPILE_CMMFLAGS += -fobjc-exceptions
+endif
+
+COMPILE_CFLAGS	= $(VISIBILITY_FLAGS) $(DEFINES) $(INCLUDES) $(XCFLAGS) $(PROFILER_CFLAGS) $(DSO_CFLAGS) $(DSO_PIC_CFLAGS) $(CFLAGS) $(RTL_FLAGS) $(OS_COMPILE_CFLAGS)
+COMPILE_CXXFLAGS = $(VISIBILITY_FLAGS) $(DEFINES) $(INCLUDES) $(XCFLAGS) $(PROFILER_CFLAGS) $(DSO_CFLAGS) $(DSO_PIC_CFLAGS)  $(CXXFLAGS) $(RTL_FLAGS) $(OS_COMPILE_CXXFLAGS)
+COMPILE_CMFLAGS = $(OS_COMPILE_CMFLAGS)
+COMPILE_CMMFLAGS = $(OS_COMPILE_CMMFLAGS)
+
+ifndef CROSS_COMPILE
+HOST_CFLAGS += $(RTL_FLAGS)
+endif
+
+#
+# Name of the binary code directories
+#
+# Override defaults
+
+# We need to know where to find the libraries we
+# put on the link line for binaries, and should
+# we link statically or dynamic?  Assuming dynamic for now.
+
+ifneq ($(MOZ_OS2_TOOLS),VACPP)
+ifneq (WINNT_,$(OS_ARCH)_$(GNU_CC))
+ifneq (,$(filter-out WINCE,$(OS_ARCH)))
+LIBS_DIR	= -L$(DIST)/bin -L$(DIST)/lib
+ifdef LIBXUL_SDK
+LIBS_DIR	+= -L$(LIBXUL_SDK)/bin -L$(LIBXUL_SDK)/lib
+endif
+endif
+endif
+endif
+
+# Default location of include files
+IDL_DIR		= $(DIST)/idl
+ifdef MODULE
+PUBLIC		= $(DIST)/include/$(MODULE)
+else
+PUBLIC		= $(DIST)/include
+endif
+
+XPIDL_FLAGS = -I$(srcdir) -I$(IDL_DIR)
+ifdef LIBXUL_SDK
+XPIDL_FLAGS += -I$(LIBXUL_SDK)/idl
+endif
+
+SDK_PUBLIC  = $(DIST)/sdk/include
+SDK_IDL_DIR = $(DIST)/sdk/idl
+SDK_LIB_DIR = $(DIST)/sdk/lib
+SDK_BIN_DIR = $(DIST)/sdk/bin
+
+DEPENDENCIES	= .md
+
+MOZ_COMPONENT_LIBS=$(XPCOM_LIBS) $(MOZ_COMPONENT_NSPR_LIBS)
+
+ifdef GC_LEAK_DETECTOR
+XPCOM_LIBS += -lboehm
+endif
+
+ifeq (xpconnect, $(findstring xpconnect, $(BUILD_MODULES)))
+DEFINES +=  -DXPCONNECT_STANDALONE
+endif
+
+ifeq ($(OS_ARCH),OS2)
+ELF_DYNSTR_GC	= echo
+else
+ELF_DYNSTR_GC	= :
+endif
+
+ifndef CROSS_COMPILE
+ifdef USE_ELF_DYNSTR_GC
+ifdef MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS
+ELF_DYNSTR_GC 	= $(MOZDEPTH)/config/elf-dynstr-gc
+endif
+endif
+endif
+
+ifeq ($(OS_ARCH),Darwin)
+ifdef USE_PREBINDING
+export LD_PREBIND=1
+export LD_SEG_ADDR_TABLE=$(shell cd $(MOZILLA_SRCDIR); pwd)/config/prebind-address-table
+endif # USE_PREBINDING
+ifdef NEXT_ROOT
+export NEXT_ROOT
+PBBUILD = NEXT_ROOT= $(PBBUILD_BIN)
+else # NEXT_ROOT
+PBBUILD = $(PBBUILD_BIN)
+endif # NEXT_ROOT
+PBBUILD_SETTINGS = GCC_VERSION="$(GCC_VERSION)" SYMROOT=build ARCHS="$(OS_TEST)"
+ifdef MACOS_SDK_DIR
+PBBUILD_SETTINGS += SDKROOT="$(MACOS_SDK_DIR)"
+endif # MACOS_SDK_DIR
+ifdef MACOSX_DEPLOYMENT_TARGET
+export MACOSX_DEPLOYMENT_TARGET
+PBBUILD_SETTINGS += MACOSX_DEPLOYMENT_TARGET="$(MACOSX_DEPLOYMENT_TARGET)"
+endif # MACOSX_DEPLOYMENT_TARGET
+ifdef MOZ_OPTIMIZE
+ifeq (2,$(MOZ_OPTIMIZE))
+# Only override project defaults if the config specified explicit settings
+PBBUILD_SETTINGS += GCC_MODEL_TUNING= OPTIMIZATION_CFLAGS="$(MOZ_OPTIMIZE_FLAGS)"
+endif # MOZ_OPTIMIZE=2
+endif # MOZ_OPTIMIZE
+ifeq (1,$(HAS_XCODE_2_1))
+# Xcode 2.1 puts its build products in a directory corresponding to the
+# selected build style/configuration.
+XCODE_PRODUCT_DIR = build/$(BUILDSTYLE)
+else
+XCODE_PRODUCT_DIR = build
+endif # HAS_XCODE_2_1=1
+endif # OS_ARCH=Darwin
+
+
+ifdef MOZ_NATIVE_MAKEDEPEND
+MKDEPEND_DIR	=
+MKDEPEND	= $(CYGWIN_WRAPPER) $(MOZ_NATIVE_MAKEDEPEND)
+else
+MKDEPEND_DIR	= $(CONFIG_TOOLS)/mkdepend
+MKDEPEND	= $(CYGWIN_WRAPPER) $(MKDEPEND_DIR)/mkdepend$(BIN_SUFFIX)
+endif
+
+# Set link flags according to whether we want a console.
+ifdef MOZ_WINCONSOLE
+ifeq ($(MOZ_WINCONSOLE),1)
+ifeq ($(MOZ_OS2_TOOLS),EMX)
+BIN_FLAGS	+= -Zlinker -PM:VIO
+endif
+ifeq ($(OS_ARCH),WINNT)
+ifdef GNU_CC
+WIN32_EXE_LDFLAGS	+= -mconsole
+else
+WIN32_EXE_LDFLAGS	+= -SUBSYSTEM:CONSOLE
+endif
+endif
+else # MOZ_WINCONSOLE
+ifeq ($(MOZ_OS2_TOOLS),VACPP)
+LDFLAGS += -PM:PM
+endif
+ifeq ($(MOZ_OS2_TOOLS),EMX)
+BIN_FLAGS	+= -Zlinker -PM:PM
+endif
+ifeq ($(OS_ARCH),WINNT)
+ifdef GNU_CC
+WIN32_EXE_LDFLAGS	+= -mwindows
+else
+WIN32_EXE_LDFLAGS	+= -SUBSYSTEM:WINDOWS
+endif
+endif
+endif
+endif
+
+# Flags needed to link against the component library
+ifdef MOZ_COMPONENTLIB
+MOZ_COMPONENTLIB_EXTRA_DSO_LIBS = mozcomps xpcom_compat
+
+# Tell the linker where NSS is, if we're building crypto
+ifeq ($(OS_ARCH),Darwin)
+ifeq (,$(findstring crypto,$(MOZ_META_COMPONENTS)))
+MOZ_COMPONENTLIB_EXTRA_LIBS = $(foreach library, $(patsubst -l%, $(LIB_PREFIX)%$(DLL_SUFFIX), $(filter -l%, $(NSS_LIBS))), -dylib_file @executable_path/$(library):$(DIST)/bin/$(library))
+endif
+endif
+endif
+
+# If we're building a component on MSVC, we don't want to generate an
+# import lib, because that import lib will collide with the name of a
+# static version of the same library.
+ifeq ($(GNU_LD)$(OS_ARCH),WINNT)
+ifdef IS_COMPONENT
+LDFLAGS += -IMPLIB:fake.lib
+DELETE_AFTER_LINK = fake.lib fake.exp
+endif
+endif
+
+#
+# Include any personal overrides the user might think are needed.
+#
+-include $(topsrcdir)/$(MOZ_BUILD_APP)/app-config.mk
+-include $(MY_CONFIG)
+
+######################################################################
+# Now test variables that might have been set or overridden by $(MY_CONFIG).
+
+DEFINES		+= -DOSTYPE=\"$(OS_CONFIG)\"
+DEFINES		+= -DOSARCH=$(OS_ARCH)
+
+# For profiling
+ifdef ENABLE_EAZEL_PROFILER
+ifndef INTERNAL_TOOLS
+ifneq ($(LIBRARY_NAME), xpt)
+ifneq (, $(findstring $(shell $(MOZILLA_SRCDIR)/build/unix/print-depth-path.sh | awk -F/ '{ print $$2; }'), $(MOZ_PROFILE_MODULES)))
+PROFILER_CFLAGS	= $(EAZEL_PROFILER_CFLAGS) -DENABLE_EAZEL_PROFILER
+PROFILER_LIBS	= $(EAZEL_PROFILER_LIBS)
+endif
+endif
+endif
+endif
+
+######################################################################
+
+GARBAGE		+= $(DEPENDENCIES) $(MKDEPENDENCIES) $(MKDEPENDENCIES).bak core $(wildcard core.[0-9]*) $(wildcard *.err) $(wildcard *.pure) $(wildcard *_pure_*.o) Templates.DB
+
+ifeq ($(OS_ARCH),Darwin)
+ifndef NSDISTMODE
+NSDISTMODE=absolute_symlink
+endif
+PWD := $(shell pwd)
+endif
+
+ifdef NSINSTALL_BIN
+NSINSTALL	= $(CYGWIN_WRAPPER) $(NSINSTALL_BIN)
+else
+ifeq (WINNT,$(CROSS_COMPILE)$(OS_ARCH))
+NSINSTALL	= $(CYGWIN_WRAPPER) $(MOZ_TOOLS_DIR)/bin/nsinstall
+else
+ifeq (OS2,$(CROSS_COMPILE)$(OS_ARCH))
+NSINSTALL	= $(MOZ_TOOLS_DIR)/nsinstall
+else
+NSINSTALL	= $(CONFIG_TOOLS)/nsinstall
+endif # OS2
+endif # WINNT
+endif # NSINSTALL_BIN
+
+
+ifeq (,$(CROSS_COMPILE)$(filter-out 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
+ifeq ($(OS_ARCH),Darwin)
+INSTALL		= $(NSINSTALL) -L $(PWD)
+else
+INSTALL		= $(NSINSTALL) -L `$(NFSPWD)`
+endif # Darwin
+else
+# install using relative symbolic links
+INSTALL		= $(NSINSTALL) -R
+endif # absolute_symlink
+endif # copy
+endif # WINNT/OS2
+
+ifeq (,$(filter-out WINCE,$(OS_ARCH)))
+NSINSTALL	= $(CYGWIN_WRAPPER) nsinstall
+INSTALL     = $(CYGWIN_WRAPPER) nsinstall 
+endif
+
+# Use nsinstall in copy mode to install files on the system
+SYSINSTALL	= $(NSINSTALL) -t
+
+ifeq ($(OS_ARCH),WINNT)
+ifneq (,$(CYGDRIVE_MOUNT))
+export CYGDRIVE_MOUNT
+endif
+endif
+
+#
+# Localization build automation
+#
+
+# Because you might wish to "make locales AB_CD=ab-CD", we don't hardcode
+# MOZ_UI_LOCALE directly, but use an intermediate variable that can be
+# overridden by the command line. (Besides, AB_CD is prettier).
+AB_CD = $(MOZ_UI_LOCALE)
+
+EXPAND_LOCALE_SRCDIR = $(if $(filter en-US,$(AB_CD)),$(topsrcdir)/$(1)/en-US,$(topsrcdir)/../l10n/$(AB_CD)/$(subst /locales,,$(1)))
+EXPAND_MOZLOCALE_SRCDIR = $(if $(filter en-US,$(AB_CD)),$(MOZILLA_SRCDIR)/$(1)/en-US,$(MOZILLA_SRCDIR)/../l10n/$(AB_CD)/$(subst /locales,,$(1)))
+
+ifdef relativesrcdir
+LOCALE_SRCDIR = $(call EXPAND_LOCALE_SRCDIR,$(relativesrcdir))
+endif
+
+ifdef LOCALE_SRCDIR
+MAKE_JARS_FLAGS += -c $(LOCALE_SRCDIR)
+endif
+
+ifeq (,$(filter WINCE WINNT OS2,$(OS_ARCH)))
+RUN_TEST_PROGRAM = $(DIST)/bin/run-mozilla.sh
+endif
+
+#
+# Java macros
+#
+
+# Make sure any compiled classes work with at least JVM 1.4
+JAVAC_FLAGS += -source 1.4
+
+ifdef MOZ_DEBUG
+JAVAC_FLAGS += -g
+endif
new file mode 100644
--- /dev/null
+++ b/config/rules.mk
@@ -0,0 +1,2242 @@
+# vim:set ts=8 sw=8 sts=8 noet:
+#
+# ***** BEGIN LICENSE BLOCK *****
+# Version: MPL 1.1/GPL 2.0/LGPL 2.1
+#
+# The contents of this file are subject to the Mozilla Public License Version
+# 1.1 (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+# http://www.mozilla.org/MPL/
+#
+# Software distributed under the License is distributed on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+# for the specific language governing rights and limitations under the
+# License.
+#
+# The Original Code is mozilla.org code.
+#
+# The Initial Developer of the Original Code is
+# Netscape Communications Corporation.
+# Portions created by the Initial Developer are Copyright (C) 1998
+# the Initial Developer. All Rights Reserved.
+#
+# Contributor(s):
+#  Chase Phillips <chase@mozilla.org>
+#  Benjamin Smedberg <benjamin@smedbergs.us>
+#  Jeff Walden <jwalden+code@mit.edu>
+#
+# Alternatively, the contents of this file may be used under the terms of
+# either of the GNU General Public License Version 2 or later (the "GPL"),
+# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+# in which case the provisions of the GPL or the LGPL are applicable instead
+# of those above. If you wish to allow use of your version of this file only
+# under the terms of either the GPL or the LGPL, and not to allow others to
+# use your version of this file under the terms of the MPL, indicate your
+# decision by deleting the provisions above and replace them with the notice
+# and other provisions required by the GPL or the LGPL. If you do not delete
+# the provisions above, a recipient may use your version of this file under
+# the terms of any one of the MPL, the GPL or the LGPL.
+#
+# ***** END LICENSE BLOCK *****
+ifndef topsrcdir
+topsrcdir		= $(DEPTH)
+endif
+
+ifndef MOZILLA_DIR
+MOZILLA_DIR = $(MOZILLA_SRCDIR)
+endif
+
+ifndef INCLUDED_CONFIG_MK
+include $(topsrcdir)/config/config.mk
+endif
+
+ifndef INCLUDED_VERSION_MK
+include $(topsrcdir)/config/version.mk
+endif
+
+REPORT_BUILD = @echo $(notdir $<)
+
+ifeq ($(OS_ARCH),OS2)
+EXEC			=
+else
+EXEC			= exec
+endif
+
+# ELOG prints out failed command when building silently (gmake -s).
+ifneq (,$(findstring -s,$(MAKEFLAGS)))
+  ELOG := $(EXEC) sh $(BUILD_TOOLS)/print-failed-commands.sh
+else
+  ELOG :=
+endif
+
+ifeq ($(MOZ_OS2_TOOLS),VACPP)
+_LIBNAME_RELATIVE_PATHS=1
+else
+ifeq (,$(filter-out WINNT WINCE,$(OS_ARCH)))
+ifndef GNU_CC
+_LIBNAME_RELATIVE_PATHS=1
+endif
+endif
+endif
+
+ifeq (,$(filter-out WINNT WINCE,$(OS_ARCH)))
+PWD := $(shell pwd)
+_VPATH_SRCS = $(if $(filter /%,$<),$<,$(PWD)/$<)
+else
+_VPATH_SRCS = $<
+endif
+
+# Add $(DIST)/lib to VPATH so that -lfoo dependencies are followed
+VPATH += $(DIST)/lib
+ifdef LIBXUL_SDK
+VPATH += $(LIBXUL_SDK)/lib
+endif
+
+# EXPAND_LIBNAME - $(call EXPAND_LIBNAME,foo)
+# expands to foo.lib on platforms with import libs and -lfoo otherwise
+
+# EXPAND_LIBNAME_PATH - $(call EXPAND_LIBNAME_PATH,foo,dir)
+# expands to dir/foo.lib on platforms with import libs and
+# -Ldir -lfoo otherwise
+
+# EXPAND_MOZLIBNAME - $(call EXPAND_MOZLIBNAME,foo)
+# expands to $(DIST)/lib/foo.lib on platforms with import libs and
+# -lfoo otherwise
+
+ifdef _LIBNAME_RELATIVE_PATHS
+EXPAND_LIBNAME = $(foreach lib,$(1),$(LIB_PREFIX)$(lib).$(LIB_SUFFIX))
+EXPAND_LIBNAME_PATH = $(foreach lib,$(1),$(2)/$(LIB_PREFIX)$(lib).$(LIB_SUFFIX))
+EXPAND_MOZLIBNAME = $(foreach lib,$(1),$(DIST)/lib/$(LIB_PREFIX)$(lib).$(LIB_SUFFIX))
+else
+EXPAND_LIBNAME = $(addprefix -l,$(1))
+EXPAND_LIBNAME_PATH = -L$(2) $(addprefix -l,$(1))
+EXPAND_MOZLIBNAME = $(addprefix -l,$(1))
+endif
+
+ifdef EXTRA_DSO_LIBS
+EXTRA_DSO_LIBS	:= $(call EXPAND_MOZLIBNAME,$(EXTRA_DSO_LIBS))
+endif
+
+#
+# Library rules
+#
+# If BUILD_STATIC_LIBS or FORCE_STATIC_LIB is set, build a static library.
+# Otherwise, build a shared library.
+#
+
+ifndef LIBRARY
+ifdef LIBRARY_NAME
+ifneq (,$(filter OS2 WINNT WINCE,$(OS_ARCH)))
+ifdef SHORT_LIBNAME
+LIBRARY_NAME		:= $(SHORT_LIBNAME)
+endif
+endif
+LIBRARY			:= $(LIB_PREFIX)$(LIBRARY_NAME).$(LIB_SUFFIX)
+endif
+endif
+
+ifndef HOST_LIBRARY
+ifdef HOST_LIBRARY_NAME
+HOST_LIBRARY		:= $(LIB_PREFIX)$(HOST_LIBRARY_NAME).$(LIB_SUFFIX)
+endif
+endif
+
+ifdef LIBRARY
+ifneq (_1,$(FORCE_SHARED_LIB)_$(BUILD_STATIC_LIBS))
+ifdef MKSHLIB
+
+ifdef LIB_IS_C_ONLY
+MKSHLIB			= $(MKCSHLIB)
+endif
+
+ifdef MAKE_FRAMEWORK
+SHARED_LIBRARY		:= $(LIBRARY_NAME)
+else
+SHARED_LIBRARY		:= $(DLL_PREFIX)$(LIBRARY_NAME)$(DLL_SUFFIX)
+endif
+
+ifeq ($(OS_ARCH),OS2)
+DEF_FILE		:= $(SHARED_LIBRARY:.dll=.def)
+endif
+
+ifneq (,$(filter OS2 WINNT WINCE,$(OS_ARCH)))
+IMPORT_LIBRARY		:= $(LIB_PREFIX)$(LIBRARY_NAME).$(IMPORT_LIB_SUFFIX)
+endif
+
+ifdef MOZ_ENABLE_LIBXUL
+EMBED_MANIFEST_AT=2
+endif
+
+endif # MKSHLIB
+endif # FORCE_SHARED_LIB && !BUILD_STATIC_LIBS
+endif # LIBRARY
+
+ifeq (,$(BUILD_STATIC_LIBS)$(FORCE_STATIC_LIB))
+LIBRARY			:= $(NULL)
+endif
+
+ifeq (_1,$(FORCE_SHARED_LIB)_$(BUILD_STATIC_LIBS))
+SHARED_LIBRARY		:= $(NULL)
+DEF_FILE		:= $(NULL)
+IMPORT_LIBRARY		:= $(NULL)
+endif
+
+ifdef FORCE_STATIC_LIB
+ifndef FORCE_SHARED_LIB
+SHARED_LIBRARY		:= $(NULL)
+DEF_FILE		:= $(NULL)
+IMPORT_LIBRARY		:= $(NULL)
+endif
+endif
+
+ifdef FORCE_SHARED_LIB
+ifndef FORCE_STATIC_LIB
+LIBRARY			:= $(NULL)
+endif
+endif
+
+ifdef JAVA_LIBRARY_NAME
+JAVA_LIBRARY := $(JAVA_LIBRARY_NAME).jar
+endif
+
+ifeq (,$(filter-out WINNT WINCE,$(OS_ARCH)))
+ifndef GNU_CC
+
+# Previously when possible we wrote to $LIBRARY_NAME.pdb.  This broke parallel
+# make builds on Windows.  Now we just write to a pdb file per compiled file.
+# See bug 286179 <https://bugzilla.mozilla.org/show_bug.cgi?id=286179> for
+# details. -- chase@mozilla.org
+#
+# Changes to the PDBFILE naming scheme should also be reflected in HOST_PDBFILE
+# 
+ifdef LIBRARY_NAME
+PDBFILE=$(LIBRARY_NAME).pdb
+ifdef MOZ_DEBUG
+CODFILE=$(LIBRARY_NAME).cod
+endif
+else
+PDBFILE=$(basename $(@F)).pdb
+ifdef MOZ_DEBUG
+CODFILE=$(basename $(@F)).cod
+endif
+endif # LIBRARY_NAME
+
+ifdef MOZ_MAPINFO
+ifdef LIBRARY_NAME
+MAPFILE=$(LIBRARY_NAME).map
+else
+MAPFILE=$(basename $(@F)).map
+endif # LIBRARY_NAME
+endif # MOZ_MAPINFO
+
+ifdef DEFFILE
+OS_LDFLAGS += -DEF:$(DEFFILE)
+EXTRA_DEPS += $(DEFFILE)
+endif
+
+ifdef MAPFILE
+OS_LDFLAGS += -MAP:$(MAPFILE)
+#CFLAGS += -Fm$(MAPFILE)
+#CXXFLAGS += -Fm$(MAPFILE)
+endif
+
+#ifdef CODFILE
+#CFLAGS += -Fa$(CODFILE) -FAsc
+#CFLAGS += -Fa$(CODFILE) -FAsc
+#endif
+
+endif # !GNU_CC
+
+ifdef ENABLE_CXX_EXCEPTIONS
+ifdef GNU_CC
+CXXFLAGS		+= -fexceptions
+else
+ifeq (,$(filter-out 1200 1300 1310,$(_MSC_VER)))
+CXXFLAGS		+= -GX
+else
+CXXFLAGS		+= -EHsc
+endif # _MSC_VER
+endif # GNU_CC
+endif # ENABLE_CXX_EXCEPTIONS
+endif # WINNT
+
+ifeq (,$(filter-out WINNT WINCE,$(HOST_OS_ARCH)))
+HOST_PDBFILE=$(basename $(@F)).pdb
+endif
+
+ifndef TARGETS
+TARGETS			= $(LIBRARY) $(SHARED_LIBRARY) $(PROGRAM) $(SIMPLE_PROGRAMS) $(HOST_LIBRARY) $(HOST_PROGRAM) $(HOST_SIMPLE_PROGRAMS) $(JAVA_LIBRARY)
+endif
+
+ifndef OBJS
+_OBJS			= \
+	$(JRI_STUB_CFILES) \
+	$(addsuffix .$(OBJ_SUFFIX), $(JMC_GEN)) \
+	$(CSRCS:.c=.$(OBJ_SUFFIX)) \
+	$(patsubst %.cc,%.$(OBJ_SUFFIX),$(CPPSRCS:.cpp=.$(OBJ_SUFFIX))) \
+	$(CMSRCS:.m=.$(OBJ_SUFFIX)) \
+	$(CMMSRCS:.mm=.$(OBJ_SUFFIX)) \
+	$(ASFILES:.$(ASM_SUFFIX)=.$(OBJ_SUFFIX))
+OBJS	= $(strip $(_OBJS))
+endif
+
+ifndef HOST_OBJS
+_HOST_OBJS		= \
+        $(addprefix host_,$(HOST_CSRCS:.c=.$(OBJ_SUFFIX))) \
+	$(addprefix host_,$(patsubst %.cc,%.$(OBJ_SUFFIX),$(HOST_CPPSRCS:.cpp=.$(OBJ_SUFFIX)))) \
+	$(addprefix host_,$(HOST_CMSRCS:.m=.$(OBJ_SUFFIX))) \
+	$(addprefix host_,$(HOST_CMMSRCS:.mm=.$(OBJ_SUFFIX)))
+HOST_OBJS = $(strip $(_HOST_OBJS))
+endif
+
+ifeq ($(MOZ_OS2_TOOLS),VACPP)
+LIBOBJS			:= $(OBJS)
+else
+LIBOBJS			:= $(addprefix \", $(OBJS))
+LIBOBJS			:= $(addsuffix \", $(LIBOBJS))
+endif
+
+ifndef MOZ_AUTO_DEPS
+ifneq (,$(OBJS)$(XPIDLSRCS)$(SDK_XPIDLSRCS)$(SIMPLE_PROGRAMS))
+MDDEPFILES		= $(addprefix $(MDDEPDIR)/,$(OBJS:.$(OBJ_SUFFIX)=.pp))
+ifndef NO_GEN_XPT
+MDDEPFILES		+= $(addprefix $(MDDEPDIR)/,$(XPIDLSRCS:.idl=.xpt)) \
+			   $(addprefix $(MDDEPDIR)/,$(SDK_XPIDLSRCS:.idl=.xpt))
+endif
+endif
+endif
+
+ALL_TRASH = \
+	$(GARBAGE) $(TARGETS) $(OBJS) $(PROGOBJS) LOGS TAGS a.out \
+	$(OBJS:.$(OBJ_SUFFIX)=.s) $(OBJS:.$(OBJ_SUFFIX)=.ii) \
+	$(OBJS:.$(OBJ_SUFFIX)=.i) \
+	$(HOST_PROGOBJS) $(HOST_OBJS) $(IMPORT_LIBRARY) $(DEF_FILE)\
+	$(EXE_DEF_FILE) so_locations _gen _stubs $(wildcard *.res) $(wildcard *.RES) \
+	$(wildcard *.pdb) $(CODFILE) $(MAPFILE) $(IMPORT_LIBRARY) \
+	$(SHARED_LIBRARY:$(DLL_SUFFIX)=.exp) $(wildcard *.ilk) \
+	$(PROGRAM:$(BIN_SUFFIX)=.exp) $(SIMPLE_PROGRAMS:$(BIN_SUFFIX)=.exp) \
+	$(PROGRAM:$(BIN_SUFFIX)=.lib) $(SIMPLE_PROGRAMS:$(BIN_SUFFIX)=.lib) \
+	$(SIMPLE_PROGRAMS:$(BIN_SUFFIX)=.$(OBJ_SUFFIX)) \
+	$(wildcard gts_tmp_*) $(LIBRARY:%.a=.%.timestamp)
+ALL_TRASH_DIRS = \
+	$(GARBAGE_DIRS) /no-such-file
+
+ifdef SIMPLE_PROGRAMS
+GARBAGE			+= $(SIMPLE_PROGRAMS:%=%.$(OBJ_SUFFIX))
+endif
+
+ifdef HOST_SIMPLE_PROGRAMS
+GARBAGE			+= $(HOST_SIMPLE_PROGRAMS:%=%.$(OBJ_SUFFIX))
+endif
+
+#
+# the Solaris WorkShop template repository cache.  it occasionally can get
+# out of sync, so targets like clobber should kill it.
+#
+ifeq ($(OS_ARCH),SunOS)
+ifeq ($(GNU_CXX),)
+GARBAGE_DIRS += SunWS_cache
+endif
+endif
+
+ifeq ($(OS_ARCH),OpenVMS)
+GARBAGE			+= $(wildcard *.*_defines)
+ifdef SHARED_LIBRARY
+VMS_SYMVEC_FILE		= $(SHARED_LIBRARY:$(DLL_SUFFIX)=_symvec.opt)
+ifdef MOZ_DEBUG
+VMS_SYMVEC_FILE_MODULE	= $(MOZILLA_SRCDIR)/build/unix/vms/$(notdir $(SHARED_LIBRARY:$(DLL_SUFFIX)=_dbg_symvec.opt))
+else
+VMS_SYMVEC_FILE_MODULE	= $(MOZILLA_SRCDIR)/build/unix/vms/$(notdir $(SHARED_LIBRARY:$(DLL_SUFFIX)=_symvec.opt))
+endif
+VMS_SYMVEC_FILE_COMP	= $(MOZILLA_SRCDIR)/build/unix/vms/component_symvec.opt
+GARBAGE			+= $(VMS_SYMVEC_FILE)
+ifdef IS_COMPONENT
+DSO_LDOPTS := $(filter-out -auto_symvec,$(DSO_LDOPTS)) $(VMS_SYMVEC_FILE)
+endif
+endif
+endif
+
+XPIDL_GEN_DIR		= _xpidlgen
+
+ifdef MOZ_UPDATE_XTERM
+# Its good not to have a newline at the end of the titlebar string because it
+# makes the make -s output easier to read.  Echo -n does not work on all
+# platforms, but we can trick sed into doing it.
+UPDATE_TITLE = sed -e "s!Y!$@ in $(shell $(BUILD_TOOLS)/print-depth-path.sh)/$(dir)!" $(MOZILLA_DIR)/config/xterm.str;
+endif
+
+LOOP_OVER_DIRS = \
+    @$(EXIT_ON_ERROR) \
+    $(foreach dir,$(DIRS),$(UPDATE_TITLE) $(MAKE) -C $(dir) $@; ) true
+
+LOOP_OVER_STATIC_DIRS = \
+    @$(EXIT_ON_ERROR) \
+    $(foreach dir,$(STATIC_DIRS),$(UPDATE_TITLE) $(MAKE) -C $(dir) $@; ) true
+
+LOOP_OVER_TOOL_DIRS = \
+    @$(EXIT_ON_ERROR) \
+    $(foreach dir,$(TOOL_DIRS),$(UPDATE_TITLE) $(MAKE) -C $(dir) $@; ) true
+
+#
+# Now we can differentiate between objects used to build a library, and
+# objects used to build an executable in the same directory.
+#
+ifndef PROGOBJS
+PROGOBJS		= $(OBJS)
+endif
+
+ifndef HOST_PROGOBJS
+HOST_PROGOBJS		= $(HOST_OBJS)
+endif
+
+# MAKE_DIRS: List of directories to build while looping over directories.
+ifneq (,$(OBJS)$(XPIDLSRCS)$(SDK_XPIDLSRCS)$(SIMPLE_PROGRAMS))
+MAKE_DIRS		+= $(MDDEPDIR)
+GARBAGE_DIRS		+= $(MDDEPDIR)
+endif
+
+#
+# Tags: emacs (etags), vi (ctags)
+# TAG_PROGRAM := ctags -L -
+#
+TAG_PROGRAM		= xargs etags -a
+
+#
+# Turn on C++ linking if we have any .cpp or .mm files
+# (moved this from config.mk so that config.mk can be included 
+#  before the CPPSRCS are defined)
+#
+ifneq ($(CPPSRCS)$(CMMSRCS),)
+CPP_PROG_LINK		= 1
+endif
+
+#
+# Make sure to wrap static libs inside linker specific flags to turn on & off
+# inclusion of all symbols inside the static libs
+#
+ifndef NO_LD_ARCHIVE_FLAGS
+ifdef SHARED_LIBRARY_LIBS
+EXTRA_DSO_LDOPTS := $(MKSHLIB_FORCE_ALL) $(SHARED_LIBRARY_LIBS) $(MKSHLIB_UNFORCE_ALL) $(EXTRA_DSO_LDOPTS)
+endif
+endif
+
+#
+# This will strip out symbols that the component should not be 
+# exporting from the .dynsym section.
+#
+ifdef IS_COMPONENT
+EXTRA_DSO_LDOPTS += $(MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS)
+endif # IS_COMPONENT
+
+#
+# Enforce the requirement that MODULE_NAME must be set 
+# for components in static builds
+#
+ifdef IS_COMPONENT
+ifdef EXPORT_LIBRARY
+ifndef FORCE_SHARED_LIB
+ifndef MODULE_NAME
+$(error MODULE_NAME is required for components which may be used in static builds)
+endif
+endif
+endif
+endif
+
+#
+# MacOS X specific stuff
+#
+
+ifeq ($(OS_ARCH),Darwin)
+ifdef SHARED_LIBRARY
+ifdef IS_COMPONENT
+EXTRA_DSO_LDOPTS	+= -bundle
+else
+EXTRA_DSO_LDOPTS	+= -dynamiclib -install_name @executable_path/$(SHARED_LIBRARY) -compatibility_version 1 -current_version 1 -single_module
+endif
+endif
+endif
+
+#
+# On NetBSD a.out systems, use -Bsymbolic.  This fixes what would otherwise be
+# fatal symbol name clashes between components.
+#
+ifeq ($(OS_ARCH),NetBSD)
+ifeq ($(DLL_SUFFIX),.so.1.0)
+ifdef IS_COMPONENT
+EXTRA_DSO_LDOPTS += -Wl,-Bsymbolic
+endif
+endif
+endif
+
+ifeq ($(OS_ARCH),FreeBSD)
+ifdef IS_COMPONENT
+EXTRA_DSO_LDOPTS += -Wl,-Bsymbolic
+endif
+endif
+
+ifeq ($(OS_ARCH),NetBSD)
+ifneq (,$(filter arc cobalt hpcmips mipsco newsmips pmax sgimips,$(OS_TEST)))
+ifeq ($(MODULE),layout)
+OS_CFLAGS += -Wa,-xgot
+OS_CXXFLAGS += -Wa,-xgot
+endif
+endif
+endif
+
+ifeq ($(OS_ARCH),Linux)
+ifneq (,$(filter mips mipsel,$(OS_TEST)))
+ifeq ($(MODULE),layout)
+OS_CFLAGS += -Wa,-xgot
+OS_CXXFLAGS += -Wa,-xgot
+endif
+endif
+endif
+
+#
+# HP-UXBeOS specific section: for COMPONENTS only, add -Bsymbolic flag
+# which uses internal symbols first
+#
+ifeq ($(OS_ARCH),HP-UX)
+ifdef IS_COMPONENT
+ifeq ($(GNU_CC)$(GNU_CXX),)
+EXTRA_DSO_LDOPTS += -Wl,-Bsymbolic
+ifneq ($(HAS_EXTRAEXPORTS),1)
+MKSHLIB  += -Wl,+eNSGetModule -Wl,+eerrno
+MKCSHLIB += +eNSGetModule +eerrno
+ifneq ($(OS_TEST),ia64)
+MKSHLIB  += -Wl,+e_shlInit
+MKCSHLIB += +e_shlInit
+endif # !ia64
+endif # !HAS_EXTRAEXPORTS
+endif # non-gnu compilers
+endif # IS_COMPONENT
+endif # HP-UX
+
+ifeq ($(OS_ARCH),AIX)
+ifdef IS_COMPONENT
+ifneq ($(HAS_EXTRAEXPORTS),1)
+MKSHLIB += -bE:$(MOZILLA_DIR)/build/unix/aix.exp -bnoexpall
+MKCSHLIB += -bE:$(MOZILLA_DIR)/build/unix/aix.exp -bnoexpall
+endif # HAS_EXTRAEXPORTS
+endif # IS_COMPONENT
+endif # AIX
+
+#
+# OSF1: add -B symbolic flag for components
+#
+ifeq ($(OS_ARCH),OSF1)
+ifdef IS_COMPONENT
+ifeq ($(GNU_CC)$(GNU_CXX),)
+EXTRA_DSO_LDOPTS += -B symbolic
+endif  
+endif  
+endif
+
+#
+# Linux: add -Bsymbolic flag for components
+# 
+ifeq ($(OS_ARCH),Linux)
+ifdef IS_COMPONENT
+EXTRA_DSO_LDOPTS += -Wl,-Bsymbolic
+endif
+endif 
+
+#
+# MINGW32
+#
+ifeq ($(OS_ARCH),WINNT)
+ifdef GNU_CC
+ifndef IS_COMPONENT
+DSO_LDOPTS += -Wl,--out-implib -Wl,$(IMPORT_LIBRARY)
+endif
+endif
+endif
+
+ifeq ($(USE_TVFS),1)
+IFLAGS1 = -rb
+IFLAGS2 = -rb
+else
+IFLAGS1 = -m 644
+IFLAGS2 = -m 755
+endif
+
+ifeq ($(MOZ_OS2_TOOLS),VACPP)
+OUTOPTION = -Fo# eol
+else
+ifeq (_WINNT,$(GNU_CC)_$(OS_ARCH))
+OUTOPTION = -Fo# eol
+else
+OUTOPTION = -o # eol
+endif # WINNT && !GNU_CC
+endif # VACPP
+ifneq (,$(filter WINCE,$(OS_ARCH)))
+OUTOPTION = -Fo# eol
+endif
+
+ifeq ($(OS_TARGET), WINCE)
+OUTOPTION = -Fo# eol
+HOST_OUTOPTION = -Fo# eol
+else
+
+ifeq (,$(CROSS_COMPILE))
+HOST_OUTOPTION = $(OUTOPTION)
+else
+HOST_OUTOPTION = -o # eol
+endif
+
+endif
+################################################################################
+
+# SUBMAKEFILES: List of Makefiles for next level down.
+#   This is used to update or create the Makefiles before invoking them.
+SUBMAKEFILES += $(addsuffix /Makefile, $(DIRS) $(TOOL_DIRS))
+
+# The root makefile doesn't want to do a plain export/libs, because
+# of the tiers and because of libxul. Suppress the default rules in favor
+# of something else. Makefiles which use this var *must* provide a sensible
+# default rule before including rules.mk
+ifndef SUPPRESS_DEFAULT_RULES
+ifdef TIERS
+
+DIRS += $(foreach tier,$(TIERS),$(tier_$(tier)_dirs))
+STATIC_DIRS += $(foreach tier,$(TIERS),$(tier_$(tier)_staticdirs))
+
+default all alldep::
+	$(EXIT_ON_ERROR) \
+	$(foreach tier,$(TIERS),$(MAKE) tier_$(tier); ) true
+
+else
+
+default all::
+	@$(EXIT_ON_ERROR) \
+	$(foreach dir,$(STATIC_DIRS),$(MAKE) -C $(dir); ) true
+	$(MAKE) export
+	$(MAKE) libs
+	$(MAKE) tools
+
+# Do depend as well
+alldep:: 
+	$(MAKE) export
+	$(MAKE) depend
+	$(MAKE) libs
+	$(MAKE) tools
+
+endif # TIERS
+endif # SUPPRESS_DEFAULT_RULES
+
+ifeq ($(filter s,$(MAKEFLAGS)),)
+ECHO := echo
+QUIET :=
+else
+ECHO := true
+QUIET := -q
+endif
+
+MAKE_TIER_SUBMAKEFILES = +$(if $(tier_$*_dirs),$(MAKE) $(addsuffix /Makefile,$(tier_$*_dirs)))
+
+export_tier_%: 
+	@$(ECHO) "$@"
+	@$(MAKE_TIER_SUBMAKEFILES)
+	@$(EXIT_ON_ERROR) \
+	$(foreach dir,$(tier_$*_dirs),$(MAKE) -C $(dir) export; ) true
+
+libs_tier_%:
+	@$(ECHO) "$@"
+	@$(MAKE_TIER_SUBMAKEFILES)
+	@$(EXIT_ON_ERROR) \
+	$(foreach dir,$(tier_$*_dirs),$(MAKE) -C $(dir) libs; ) true
+
+tools_tier_%:
+	@$(ECHO) "$@"
+	@$(MAKE_TIER_SUBMAKEFILES)
+	@$(EXIT_ON_ERROR) \
+	$(foreach dir,$(tier_$*_dirs),$(MAKE) -C $(dir) tools; ) true
+
+$(foreach tier,$(TIERS),tier_$(tier))::
+	@$(ECHO) "$@: $($@_staticdirs) $($@_dirs)"
+	@$(EXIT_ON_ERROR) \
+	$(foreach dir,$($@_staticdirs),$(MAKE) -C $(dir); ) true
+	$(MAKE) export_$@
+	$(MAKE) libs_$@
+
+# Do everything from scratch
+everything::
+	$(MAKE) clean
+	$(MAKE) alldep
+
+# Add dummy depend target for tinderboxes
+depend::
+
+ifdef ALL_PLATFORMS
+all_platforms:: $(NFSPWD)
+	@d=`$(NFSPWD)`;							\
+	if test ! -d LOGS; then rm -rf LOGS; mkdir LOGS; else true; fi;	\
+	for h in $(PLATFORM_HOSTS); do					\
+		echo "On $$h: $(MAKE) $(ALL_PLATFORMS) >& LOGS/$$h.log";\
+		rsh $$h -n "(chdir $$d;					\
+			     $(MAKE) $(ALL_PLATFORMS) >& LOGS/$$h.log;	\
+			     echo DONE) &" 2>&1 > LOGS/$$h.pid &	\
+		sleep 1;						\
+	done
+
+$(NFSPWD):
+	cd $(@D); $(MAKE) $(@F)
+endif
+
+# Target to only regenerate makefiles
+makefiles: $(SUBMAKEFILES)
+ifneq (,$(DIRS)$(TOOL_DIRS))
+	+$(LOOP_OVER_DIRS)
+	+$(LOOP_OVER_TOOL_DIRS)
+endif
+
+export:: $(SUBMAKEFILES) $(MAKE_DIRS) $(if $(EXPORTS)$(XPIDLSRCS)$(SDK_HEADERS)$(SDK_XPIDLSRCS),$(PUBLIC)) $(if $(SDK_HEADERS)$(SDK_XPIDLSRCS),$(SDK_PUBLIC)) $(if $(XPIDLSRCS),$(IDL_DIR)) $(if $(SDK_XPIDLSRCS),$(SDK_IDL_DIR))
+	+$(LOOP_OVER_DIRS)
+	+$(LOOP_OVER_TOOL_DIRS)
+
+tools:: $(SUBMAKEFILES) $(MAKE_DIRS)
+	+$(LOOP_OVER_DIRS)
+ifdef TOOL_DIRS
+	@$(EXIT_ON_ERROR) \
+	$(foreach dir,$(TOOL_DIRS),$(UPDATE_TITLE) $(MAKE) -C $(dir) libs; ) true
+endif
+
+#
+# Rule to create list of libraries for final link
+#
+export::
+ifdef LIBRARY_NAME
+ifdef EXPORT_LIBRARY
+ifdef IS_COMPONENT
+ifdef BUILD_STATIC_LIBS
+	@$(PERL) -I$(MOZILLA_DIR)/config $(MOZILLA_DIR)/config/build-list.pl $(FINAL_LINK_COMPS) $(LIBRARY_NAME)
+ifdef MODULE_NAME
+	@$(PERL) -I$(MOZILLA_DIR)/config $(MOZILLA_DIR)/config/build-list.pl $(FINAL_LINK_COMP_NAMES) $(MODULE_NAME)
+endif
+endif
+else
+	$(PERL) -I$(MOZILLA_DIR)/config $(MOZILLA_DIR)/config/build-list.pl $(FINAL_LINK_LIBS) $(LIBRARY_NAME)
+endif # IS_COMPONENT
+endif # EXPORT_LIBRARY
+endif # LIBRARY_NAME
+
+# Create dependencies on static (and shared EXTRA_DSO_LIBS) libraries
+LIBS_DEPS = $(filter %.$(LIB_SUFFIX), $(LIBS))
+HOST_LIBS_DEPS = $(filter %.$(LIB_SUFFIX), $(HOST_LIBS))
+DSO_LDOPTS_DEPS = $(EXTRA_DSO_LIBS) $(filter %.$(LIB_SUFFIX), $(EXTRA_DSO_LDOPTS))
+
+##############################################
+libs:: $(SUBMAKEFILES) $(MAKE_DIRS) $(HOST_LIBRARY) $(LIBRARY) $(SHARED_LIBRARY) $(IMPORT_LIBRARY) $(HOST_PROGRAM) $(PROGRAM) $(HOST_SIMPLE_PROGRAMS) $(SIMPLE_PROGRAMS) $(JAVA_LIBRARY)
+ifndef NO_DIST_INSTALL
+ifdef LIBRARY
+ifdef EXPORT_LIBRARY # Stage libs that will be linked into a static build
+ifdef IS_COMPONENT
+	$(INSTALL) $(IFLAGS1) $(LIBRARY) $(MOZDEPTH)/staticlib/components
+else
+	$(INSTALL) $(IFLAGS1) $(LIBRARY) $(MOZDEPTH)/staticlib
+endif
+endif # EXPORT_LIBRARY
+ifdef DIST_INSTALL
+ifdef IS_COMPONENT
+	$(error Shipping static component libs makes no sense.)
+else
+	$(INSTALL) $(IFLAGS1) $(LIBRARY) $(DIST)/lib
+endif
+endif # DIST_INSTALL
+endif # LIBRARY
+ifdef SHARED_LIBRARY
+ifdef IS_COMPONENT
+	$(INSTALL) $(IFLAGS2) $(SHARED_LIBRARY) $(FINAL_TARGET)/components
+	$(ELF_DYNSTR_GC) $(FINAL_TARGET)/components/$(SHARED_LIBRARY)
+ifdef BEOS_ADDON_WORKAROUND
+	( cd $(FINAL_TARGET)/components && $(CC) -nostart -o $(SHARED_LIBRARY).stub $(SHARED_LIBRARY) )
+endif
+else # ! IS_COMPONENT
+ifneq (,$(filter OS2 WINNT WINCE,$(OS_ARCH)))
+	$(INSTALL) $(IFLAGS2) $(IMPORT_LIBRARY) $(DIST)/lib
+else
+	$(INSTALL) $(IFLAGS2) $(SHARED_LIBRARY) $(DIST)/lib
+endif
+	$(INSTALL) $(IFLAGS2) $(SHARED_LIBRARY) $(FINAL_TARGET)
+ifdef BEOS_ADDON_WORKAROUND
+	( cd $(FINAL_TARGET) && $(CC) -nostart -o $(SHARED_LIBRARY).stub $(SHARED_LIBRARY) )
+endif
+endif # IS_COMPONENT
+endif # SHARED_LIBRARY
+ifdef PROGRAM
+	$(INSTALL) $(IFLAGS2) $(PROGRAM) $(FINAL_TARGET)
+endif
+ifdef SIMPLE_PROGRAMS
+	$(INSTALL) $(IFLAGS2) $(SIMPLE_PROGRAMS) $(FINAL_TARGET)
+endif
+ifdef HOST_PROGRAM
+	$(INSTALL) $(IFLAGS2) $(HOST_PROGRAM) $(DIST)/host/bin
+endif
+ifdef HOST_SIMPLE_PROGRAMS
+	$(INSTALL) $(IFLAGS2) $(HOST_SIMPLE_PROGRAMS) $(DIST)/host/bin
+endif
+ifdef HOST_LIBRARY
+	$(INSTALL) $(IFLAGS1) $(HOST_LIBRARY) $(DIST)/host/lib
+endif
+ifdef JAVA_LIBRARY
+ifdef IS_COMPONENT
+	$(INSTALL) $(IFLAGS1) $(JAVA_LIBRARY) $(FINAL_TARGET)/components
+else
+	$(INSTALL) $(IFLAGS1) $(JAVA_LIBRARY) $(FINAL_TARGET)
+endif
+endif # JAVA_LIBRARY
+endif # !NO_DIST_INSTALL
+	+$(LOOP_OVER_DIRS)
+
+##############################################
+
+ifndef NO_PROFILE_GUIDED_OPTIMIZE
+ifneq (,$(MOZ_PROFILE_GENERATE)$(MOZ_PROFILE_USE))
+ifeq ($(OS_ARCH)_$(GNU_CC)$(INTERNAL_TOOLS), WINNT_)
+# Force re-linking when building with PGO, since
+# the MSVC linker does all the work.  We force re-link
+# in both stages so you can do depend builds with PGO.
+ifdef SHARED_LIBRARY
+$(SHARED_LIBRARY): FORCE
+BINARY_BASENAME = $(SHARED_LIBRARY:$(DLL_SUFFIX)=)
+endif
+ifdef PROGRAM
+$(PROGRAM): FORCE
+BINARY_BASENAME = $(PROGRAM:$(BIN_SUFFIX)=)
+endif
+
+ifdef MOZ_PROFILE_USE
+# In the second pass, we need to merge the pgc files into the pgd file.
+# The compiler would do this for us automatically if they were in the right
+# place, but they're in dist/bin.
+ifdef BINARY_BASENAME
+export::
+	$(PYTHON) $(MOZILLA_SRCDIR)/build/win32/pgomerge.py \
+	  $(BINARY_BASENAME) $(DIST)/bin
+endif
+endif # MOZ_PROFILE_USE
+endif # WINNT_
+endif # MOZ_PROFILE_GENERATE || MOZ_PROFILE_USE
+endif # NO_PROFILE_GUIDED_OPTIMIZE
+
+##############################################
+
+checkout:
+	$(PYTHON) $(topsrcdir)/client.py checkout
+
+run_viewer: $(FINAL_TARGET)/viewer
+	cd $(FINAL_TARGET); \
+	MOZILLA_FIVE_HOME=`pwd` \
+	LD_LIBRARY_PATH=".:$(LIBS_PATH):$$LD_LIBRARY_PATH" \
+	viewer
+
+clean clobber realclean clobber_all:: $(SUBMAKEFILES)
+	-rm -f $(ALL_TRASH)
+	-rm -rf $(ALL_TRASH_DIRS)
+	+-$(LOOP_OVER_DIRS)
+	+-$(LOOP_OVER_STATIC_DIRS)
+	+-$(LOOP_OVER_TOOL_DIRS)
+
+distclean:: $(SUBMAKEFILES)
+	+-$(LOOP_OVER_DIRS)
+	+-$(LOOP_OVER_STATIC_DIRS)
+	+-$(LOOP_OVER_TOOL_DIRS)
+	-rm -rf $(ALL_TRASH_DIRS) 
+	-rm -f $(ALL_TRASH)  \
+	Makefile .HSancillary \
+	$(wildcard *.$(OBJ_SUFFIX)) $(wildcard *.ho) $(wildcard host_*.o*) \
+	$(wildcard *.$(LIB_SUFFIX)) $(wildcard *$(DLL_SUFFIX)) \
+	$(wildcard *.$(IMPORT_LIB_SUFFIX))
+ifeq ($(MOZ_OS2_TOOLS),VACPP)
+	-rm -f $(PROGRAM:.exe=.map)
+endif
+
+alltags:
+	rm -f TAGS
+	find $(topsrcdir) -name dist -prune -o \( -name '*.[hc]' -o -name '*.cp' -o -name '*.cpp' -o -name '*.idl' \) -print | $(TAG_PROGRAM)
+
+#
+# PROGRAM = Foo
+# creates OBJS, links with LIBS to create Foo
+#
+$(PROGRAM): $(PROGOBJS) $(LIBS_DEPS) $(EXTRA_DEPS) $(EXE_DEF_FILE) $(RESFILE) Makefile Makefile.in
+ifeq (WINCE,$(OS_ARCH))
+	$(LD) -NOLOGO -OUT:$@ $(WIN32_EXE_LDFLAGS) $(LDFLAGS) $(PROGOBJS) $(RESFILE) $(LIBS) $(EXTRA_LIBS) $(OS_LIBS)
+else
+ifeq ($(MOZ_OS2_TOOLS),VACPP)
+	$(LD) -OUT:$@ $(LDFLAGS) $(PROGOBJS) $(LIBS) $(EXTRA_LIBS) $(OS_LIBS) $(EXE_DEF_FILE) -ST:0x100000
+else
+
+ifeq (_WINNT,$(GNU_CC)_$(OS_ARCH))
+	$(LD) -NOLOGO -OUT:$@ -PDB:$(PDBFILE) $(WIN32_EXE_LDFLAGS) $(LDFLAGS) $(PROGOBJS) $(RESFILE) $(LIBS) $(EXTRA_LIBS) $(OS_LIBS)
+ifdef MSMANIFEST_TOOL
+	@if test -f $@.manifest; then \
+		if test -f "$(srcdir)/$@.manifest"; then \
+			mt.exe -NOLOGO -MANIFEST "$(win_srcdir)/$@.manifest" $@.manifest -OUTPUTRESOURCE:$@\;1; \
+		else \
+			mt.exe -NOLOGO -MANIFEST $@.manifest -OUTPUTRESOURCE:$@\;1; \
+		fi; \
+		rm -f $@.manifest; \
+	fi
+endif	# MSVC with manifest tool
+else
+ifeq ($(CPP_PROG_LINK),1)
+	$(CCC) -o $@ $(CXXFLAGS) $(WRAP_MALLOC_CFLAGS) $(PROGOBJS) $(RESFILE) $(WIN32_EXE_LDFLAGS) $(SOLARIS_JEMALLOC_LDFLAGS) $(LDFLAGS) $(LIBS_DIR) $(LIBS) $(OS_LIBS) $(EXTRA_LIBS) $(BIN_FLAGS) $(WRAP_MALLOC_LIB) $(PROFILER_LIBS) $(EXE_DEF_FILE)
+else # ! CPP_PROG_LINK
+	$(CC) -o $@ $(CFLAGS) $(PROGOBJS) $(RESFILE) $(WIN32_EXE_LDFLAGS) $(SOLARIS_JEMALLOC_LDFLAGS) $(LDFLAGS) $(LIBS_DIR) $(LIBS) $(OS_LIBS) $(EXTRA_LIBS) $(BIN_FLAGS) $(EXE_DEF_FILE)
+endif # CPP_PROG_LINK
+endif # WINNT && !GNU_CC
+endif # OS2
+endif # WINCE
+
+ifdef ENABLE_STRIP
+	$(STRIP) $@
+endif
+ifdef MOZ_POST_PROGRAM_COMMAND
+	$(MOZ_POST_PROGRAM_COMMAND) $@
+endif
+ifeq ($(OS_ARCH),BeOS)
+ifdef BEOS_PROGRAM_RESOURCE
+	xres -o $@ $(BEOS_PROGRAM_RESOURCE)
+	mimeset $@
+endif
+endif # BeOS
+
+$(HOST_PROGRAM): $(HOST_PROGOBJS) $(HOST_LIBS_DEPS) $(HOST_EXTRA_DEPS) Makefile Makefile.in
+ifeq ($(MOZ_OS2_TOOLS),VACPP)
+	$(LD) -OUT:$@ $(LDFLAGS) $(HOST_OBJS) $(HOST_LIBS) $(HOST_EXTRA_LIBS) -ST:0x100000
+else
+ifeq (WINCE,$(OS_ARCH))
+	$(HOST_LD) -NOLOGO -OUT:$@ $(HOST_OBJS) $(WIN32_EXE_LDFLAGS) $(HOST_LIBS) $(HOST_EXTRA_LIBS)
+else
+ifeq (_WINNT,$(GNU_CC)_$(HOST_OS_ARCH))
+	$(HOST_LD) -NOLOGO -OUT:$@ -PDB:$(PDBFILE) $(HOST_OBJS) $(WIN32_EXE_LDFLAGS) $(HOST_LIBS) $(HOST_EXTRA_LIBS)
+ifdef MSMANIFEST_TOOL
+	@if test -f $@.manifest; then \
+		mt.exe -NOLOGO -MANIFEST $@.manifest -OUTPUTRESOURCE:$@\;1; \
+		rm -f $@.manifest; \
+	fi
+endif	# MSVC with manifest tool
+else
+ifeq ($(CPP_PROG_LINK),1)
+	$(HOST_CXX) -o $@ $(HOST_CXXFLAGS) $(HOST_LDFLAGS) $(HOST_PROGOBJS) $(HOST_LIBS) $(HOST_EXTRA_LIBS)
+else
+	$(HOST_CC) -o $@ $(HOST_CFLAGS) $(HOST_LDFLAGS) $(HOST_PROGOBJS) $(HOST_LIBS) $(HOST_EXTRA_LIBS)
+endif # CPP_PROG_LINK
+endif
+endif
+endif
+
+#
+# This is an attempt to support generation of multiple binaries
+# in one directory, it assumes everything to compile Foo is in
+# Foo.o (from either Foo.c or Foo.cpp).
+#
+# SIMPLE_PROGRAMS = Foo Bar
+# creates Foo.o Bar.o, links with LIBS to create Foo, Bar.
+#
+$(SIMPLE_PROGRAMS): %$(BIN_SUFFIX): %.$(OBJ_SUFFIX) $(LIBS_DEPS) $(EXTRA_DEPS) Makefile Makefile.in
+ifeq (WINCE,$(OS_ARCH))
+	$(LD) -nologo  -entry:main -out:$@ $< $(WIN32_EXE_LDFLAGS) $(LDFLAGS) $(LIBS) $(EXTRA_LIBS) $(OS_LIBS)
+else
+ifeq ($(MOZ_OS2_TOOLS),VACPP)
+	$(LD) -Out:$@ $< $(LDFLAGS) $(LIBS) $(OS_LIBS) $(EXTRA_LIBS) $(WRAP_MALLOC_LIB) $(PROFILER_LIBS)
+else
+ifeq (_WINNT,$(GNU_CC)_$(OS_ARCH))
+	$(LD) -nologo -out:$@ -pdb:$(PDBFILE) $< $(WIN32_EXE_LDFLAGS) $(LDFLAGS) $(LIBS) $(EXTRA_LIBS) $(OS_LIBS)
+ifdef MSMANIFEST_TOOL
+	@if test -f $@.manifest; then \
+		mt.exe -NOLOGO -MANIFEST $@.manifest -OUTPUTRESOURCE:$@\;1; \
+		rm -f $@.manifest; \
+	fi
+endif	# MSVC with manifest tool
+else
+ifeq ($(CPP_PROG_LINK),1)
+	$(CCC) $(WRAP_MALLOC_CFLAGS) $(CXXFLAGS) -o $@ $< $(WIN32_EXE_LDFLAGS) $(SOLARIS_JEMALLOC_LDFLAGS) $(LDFLAGS) $(LIBS_DIR) $(LIBS) $(OS_LIBS) $(EXTRA_LIBS) $(WRAP_MALLOC_LIB) $(PROFILER_LIBS) $(BIN_FLAGS)
+else
+	$(CC) $(WRAP_MALLOC_CFLAGS) $(CFLAGS) $(OUTOPTION)$@ $< $(WIN32_EXE_LDFLAGS) $(SOLARIS_JEMALLOC_LDFLAGS) $(LDFLAGS) $(LIBS_DIR) $(LIBS) $(OS_LIBS) $(EXTRA_LIBS) $(WRAP_MALLOC_LIB) $(PROFILER_LIBS) $(BIN_FLAGS)
+endif # CPP_PROG_LINK
+endif # WINNT && !GNU_CC
+endif # OS/2 VACPP
+endif # WINCE
+
+ifdef ENABLE_STRIP
+	$(STRIP) $@
+endif
+ifdef MOZ_POST_PROGRAM_COMMAND
+	$(MOZ_POST_PROGRAM_COMMAND) $@
+endif
+
+$(HOST_SIMPLE_PROGRAMS): host_%$(HOST_BIN_SUFFIX): host_%.$(OBJ_SUFFIX) $(HOST_LIBS_DEPS) $(HOST_EXTRA_DEPS) Makefile Makefile.in
+ifeq ($(MOZ_OS2_TOOLS),VACPP)
+	$(HOST_LD) -OUT:$@ $< $(LDFLAGS) $(HOST_LIBS) $(HOST_EXTRA_LIBS) -ST:0x100000
+else
+ifeq (WINCE,$(OS_ARCH))
+	$(HOST_LD) -NOLOGO -OUT:$@ $(WIN32_EXE_LDFLAGS) $< $(HOST_LIBS) $(HOST_EXTRA_LIBS)
+else
+ifeq (WINNT_,$(HOST_OS_ARCH)_$(GNU_CC))
+	$(HOST_LD) -NOLOGO -OUT:$@ -PDB:$(PDBFILE) $< $(WIN32_EXE_LDFLAGS) $(HOST_LIBS) $(HOST_EXTRA_LIBS)
+else
+ifneq (,$(HOST_CPPSRCS)$(USE_HOST_CXX))
+	$(HOST_CXX) $(HOST_OUTOPTION)$@ $(HOST_CXXFLAGS) $(INCLUDES) $< $(HOST_LIBS) $(HOST_EXTRA_LIBS)
+else
+	$(HOST_CC) $(HOST_OUTOPTION)$@ $(HOST_CFLAGS) $(INCLUDES) $< $(HOST_LIBS) $(HOST_EXTRA_LIBS)
+endif
+endif
+endif
+endif
+
+#
+# Purify target.  Solaris/sparc only to start.
+# Purify does not recognize "egcs" or "c++" so we go with 
+# "gcc" and "g++" for now.
+#
+pure:	$(PROGRAM)
+ifeq ($(CPP_PROG_LINK),1)
+	$(PURIFY) $(CCC) -o $^.pure $(CXXFLAGS) $(PROGOBJS) $(LDFLAGS) $(LIBS_DIR) $(LIBS) $(OS_LIBS) $(EXTRA_LIBS)
+else
+	$(PURIFY) $(CC) -o $^.pure $(CFLAGS) $(PROGOBJS) $(LDFLAGS) $(LIBS_DIR) $(LIBS) $(OS_LIBS) $(EXTRA_LIBS)
+endif
+ifndef NO_DIST_INSTALL
+	$(INSTALL) $(IFLAGS2) $^.pure $(FINAL_TARGET)
+endif
+
+quantify: $(PROGRAM)
+ifeq ($(CPP_PROG_LINK),1)
+	$(QUANTIFY) $(CCC) -o $^.quantify $(CXXFLAGS) $(PROGOBJS) $(LDFLAGS) $(LIBS_DIR) $(LIBS) $(OS_LIBS) $(EXTRA_LIBS)
+else
+	$(QUANTIFY) $(CC) -o $^.quantify $(CFLAGS) $(PROGOBJS) $(LDFLAGS) $(LIBS_DIR) $(LIBS) $(OS_LIBS) $(EXTRA_LIBS)
+endif
+ifndef NO_DIST_INSTALL
+	$(INSTALL) $(IFLAGS2) $^.quantify $(FINAL_TARGET)
+endif
+
+#
+# This allows us to create static versions of the shared libraries
+# that are built using other static libraries.  Confused...?
+#
+ifdef SHARED_LIBRARY_LIBS
+ifeq (,$(GNU_LD)$(filter-out OS2 WINNT WINCE, $(OS_ARCH)))
+ifneq (,$(BUILD_STATIC_LIBS)$(FORCE_STATIC_LIB))
+LOBJS	+= $(SHARED_LIBRARY_LIBS)
+endif
+else
+ifneq (,$(filter OSF1 BSD_OS FreeBSD NetBSD OpenBSD SunOS Darwin,$(OS_ARCH)))
+CLEANUP1	:= | egrep -v '(________64ELEL_|__.SYMDEF)'
+CLEANUP2	:= rm -f ________64ELEL_ __.SYMDEF
+else
+CLEANUP2	:= true
+endif
+SUB_LOBJS	= $(shell for lib in $(SHARED_LIBRARY_LIBS); do $(AR_LIST) $${lib} $(CLEANUP1); done;)
+endif
+endif
+ifdef MOZILLA_PROBE_LIBS
+PROBE_LOBJS	= $(shell for lib in $(MOZILLA_PROBE_LIBS); do $(AR_LIST) $${lib} $(CLEANUP1); done;)
+endif
+ifdef DTRACE_PROBE_OBJ
+EXTRA_DEPS += $(DTRACE_PROBE_OBJ)
+endif
+
+$(LIBRARY): $(OBJS) $(LOBJS) $(SHARED_LIBRARY_LIBS) $(EXTRA_DEPS) Makefile Makefile.in
+	rm -f $@
+ifneq (,$(GNU_LD)$(filter-out OS2 WINNT WINCE, $(OS_ARCH)))
+ifdef SHARED_LIBRARY_LIBS
+	@rm -f $(SUB_LOBJS)
+	@for lib in $(SHARED_LIBRARY_LIBS); do $(AR_EXTRACT) $${lib}; $(CLEANUP2); done
+endif
+endif
+	$(AR) $(AR_FLAGS) $(OBJS) $(LOBJS) $(SUB_LOBJS)
+	$(RANLIB) $@
+	@rm -f foodummyfilefoo $(SUB_LOBJS)
+
+ifeq (,$(filter-out WINNT WINCE, $(OS_ARCH)))
+$(IMPORT_LIBRARY): $(SHARED_LIBRARY)
+endif
+
+ifeq ($(OS_ARCH),OS2)
+$(DEF_FILE): $(OBJS) $(SHARED_LIBRARY_LIBS)
+	rm -f $@
+	echo LIBRARY $(LIBRARY_NAME) INITINSTANCE TERMINSTANCE > $@
+	echo PROTMODE >> $@
+	echo CODE    LOADONCALL MOVEABLE DISCARDABLE >> $@
+	echo DATA    PRELOAD MOVEABLE MULTIPLE NONSHARED >> $@
+	echo EXPORTS >> $@
+ifeq ($(IS_COMPONENT),1)
+ifeq ($(HAS_EXTRAEXPORTS),1)
+ifndef MOZ_OS2_USE_DECLSPEC
+	$(FILTER) $(OBJS) $(SHARED_LIBRARY_LIBS) >> $@
+endif	
+else
+	echo    _NSGetModule >> $@
+endif
+else
+ifndef MOZ_OS2_USE_DECLSPEC
+	$(FILTER) $(OBJS) $(SHARED_LIBRARY_LIBS) >> $@
+endif	
+endif
+	$(ADD_TO_DEF_FILE)
+
+ifdef MOZ_OS2_USE_DECLSPEC
+$(IMPORT_LIBRARY): $(SHARED_LIBRARY)
+else
+$(IMPORT_LIBRARY): $(DEF_FILE)
+endif
+	rm -f $@
+	$(IMPLIB) $@ $^
+	$(RANLIB) $@
+endif # OS/2
+
+$(HOST_LIBRARY): $(HOST_OBJS) Makefile
+	rm -f $@
+	$(HOST_AR) $(HOST_AR_FLAGS) $(HOST_OBJS)
+	$(HOST_RANLIB) $@
+
+ifdef NO_LD_ARCHIVE_FLAGS
+SUB_SHLOBJS = $(SUB_LOBJS)
+endif
+
+ifdef HAVE_DTRACE
+ifndef XP_MACOSX
+ifdef DTRACE_PROBE_OBJ
+ifndef DTRACE_LIB_DEPENDENT
+$(DTRACE_PROBE_OBJ): $(OBJS)
+	dtrace -G -C -32 -s $(MOZILLA_DTRACE_SRC) -o $(DTRACE_PROBE_OBJ) $(OBJS)
+endif
+endif
+endif
+endif
+
+# On Darwin (Mac OS X), dwarf2 debugging uses debug info left in .o files,
+# so instead of deleting .o files after repacking them into a dylib, we make
+# symlinks back to the originals. The symlinks are a no-op for stabs debugging,
+# so no need to conditionalize on OS version or debugging format.
+
+$(SHARED_LIBRARY): $(OBJS) $(LOBJS) $(DEF_FILE) $(RESFILE) $(SHARED_LIBRARY_LIBS) $(EXTRA_DEPS) $(DSO_LDOPTS_DEPS) Makefile Makefile.in
+ifndef INCREMENTAL_LINKER
+	rm -f $@
+endif
+ifneq ($(MOZ_OS2_TOOLS),VACPP)
+ifeq ($(OS_ARCH),OpenVMS)
+	@if test ! -f $(VMS_SYMVEC_FILE); then \
+	  if test -f $(VMS_SYMVEC_FILE_MODULE); then \
+	    echo Creating specific component options file $(VMS_SYMVEC_FILE); \
+	    cp $(VMS_SYMVEC_FILE_MODULE) $(VMS_SYMVEC_FILE); \
+	  fi; \
+	fi
+ifdef IS_COMPONENT
+	@if test ! -f $(VMS_SYMVEC_FILE); then \
+	  echo Creating generic component options file $(VMS_SYMVEC_FILE); \
+	  cp $(VMS_SYMVEC_FILE_COMP) $(VMS_SYMVEC_FILE); \
+	fi
+endif
+endif
+ifdef NO_LD_ARCHIVE_FLAGS
+ifdef SHARED_LIBRARY_LIBS
+	@rm -f $(SUB_SHLOBJS)
+	@for lib in $(SHARED_LIBRARY_LIBS); do $(AR_EXTRACT) $${lib}; $(CLEANUP2); done
+ifeq ($(OS_ARCH),Darwin)
+	@echo Making symlinks to the original object files in the archive libraries $(SHARED_LIBRARY_LIBS)
+	@for lib in $(SHARED_LIBRARY_LIBS); do \
+		libdir=`echo $$lib|sed -e 's,/[^/]*\.a,,'`; \
+		ofiles=`$(AR_LIST) $${lib}`; \
+		for ofile in $$ofiles; do \
+			if [ -f $$libdir/$$ofile ]; then \
+				rm -f $$ofile; \
+				ln -s $$libdir/$$ofile $$ofile; \
+			fi; \
+		done; \
+	done
+endif
+endif # SHARED_LIBRARY_LIBS
+endif # NO_LD_ARCHIVE_FLAGS
+ifdef DTRACE_LIB_DEPENDENT
+	@rm -f $(PROBE_LOBJS)
+	@for lib in $(MOZILLA_PROBE_LIBS); do $(AR_EXTRACT) $${lib}; $(CLEANUP2); done
+ifndef XP_MACOSX
+	dtrace -G -C -32 -s $(MOZILLA_DTRACE_SRC) -o  $(DTRACE_PROBE_OBJ) $(PROBE_LOBJS)
+endif
+	@for lib in $(MOZILLA_PROBE_LIBS); do \
+		ofiles=`$(AR_LIST) $${lib}`; \
+		$(AR_DELETE) $${lib} $$ofiles; \
+	done
+	$(MKSHLIB) $(SHLIB_LDSTARTFILE) $(OBJS) $(LOBJS) $(SUB_SHLOBJS) $(DTRACE_PROBE_OBJ) $(PROBE_LOBJS) $(RESFILE) $(LDFLAGS) $(EXTRA_DSO_LDOPTS) $(OS_LIBS) $(EXTRA_LIBS) $(DEF_FILE) $(SHLIB_LDENDFILE)
+	@rm -f $(PROBE_LOBJS)
+	@rm -f $(DTRACE_PROBE_OBJ)
+	@for lib in $(MOZILLA_PROBE_LIBS); do \
+		if [ -L $${lib} ]; then rm -f `readlink $${lib}`; fi; \
+	done
+	@rm -f $(MOZILLA_PROBE_LIBS)
+
+else
+	$(MKSHLIB) $(SHLIB_LDSTARTFILE) $(OBJS) $(DTRACE_PROBE_OBJ) $(LOBJS) $(SUB_SHLOBJS) $(RESFILE) $(LDFLAGS) $(EXTRA_DSO_LDOPTS) $(OS_LIBS) $(EXTRA_LIBS) $(DEF_FILE) $(SHLIB_LDENDFILE)
+endif # DTRACE_LIB_DEPENDENT
+
+ifeq (_WINNT,$(GNU_CC)_$(OS_ARCH))
+ifdef MSMANIFEST_TOOL
+ifdef EMBED_MANIFEST_AT
+	@if test -f $@.manifest; then \
+		mt.exe -NOLOGO -MANIFEST $@.manifest -OUTPUTRESOURCE:$@\;$(EMBED_MANIFEST_AT); \
+		rm -f $@.manifest; \
+	fi
+endif   # EMBED_MANIFEST_AT
+endif	# MSVC with manifest tool
+endif	# WINNT && !GCC
+ifeq ($(OS_ARCH),Darwin)
+else # non-Darwin
+	@rm -f $(SUB_SHLOBJS)
+endif # Darwin
+	@rm -f foodummyfilefoo $(DELETE_AFTER_LINK)
+else # os2 vacpp
+	$(MKSHLIB) -O:$@ -DLL -INC:_dllentry $(LDFLAGS) $(OBJS) $(LOBJS) $(EXTRA_DSO_LDOPTS) $(OS_LIBS) $(EXTRA_LIBS) $(DEF_FILE)
+endif # !os2 vacpp
+	chmod +x $@
+ifdef ENABLE_STRIP
+	$(STRIP) $@
+endif
+ifdef MOZ_POST_DSO_LIB_COMMAND
+	$(MOZ_POST_DSO_LIB_COMMAND) $@
+endif
+
+ifdef MOZ_AUTO_DEPS
+ifdef COMPILER_DEPEND
+ifeq (__SunOS,$(GNU_CC)_$(GNU_CXX)_$(OS_ARCH))
+_MDDEPFILE = $(MDDEPDIR)/$(@F).pp
+
+define MAKE_DEPS_AUTO_CC
+if test -d $(@D); then \
+	echo "Building deps for $< using Sun Studio cc"; \
+	$(CC) $(COMPILE_CFLAGS) -xM  $< >$(_MDDEPFILE) ; \
+fi
+endef
+define MAKE_DEPS_AUTO_CXX
+if test -d $(@D); then \
+	echo "Building deps for $< using Sun Studio CC"; \
+	$(CXX) $(COMPILE_CXXFLAGS) -xM $< >$(_MDDEPFILE) ; \
+fi
+endef
+endif # Sun Studio on Solaris
+else # COMPILER_DEPEND
+#
+# Generate dependencies on the fly
+#
+_MDDEPFILE = $(MDDEPDIR)/$(@F).pp
+
+define MAKE_DEPS_AUTO
+if test -d $(@D); then \
+	echo "Building deps for $<"; \
+	$(MKDEPEND) -o'.$(OBJ_SUFFIX)' -f- $(DEFINES) $(ACDEFINES) $(INCLUDES) $< 2>/dev/null | sed -e "s|^[^ ]*/||" > $(_MDDEPFILE) ; \
+fi
+endef
+
+MAKE_DEPS_AUTO_CC = $(MAKE_DEPS_AUTO)
+MAKE_DEPS_AUTO_CXX = $(MAKE_DEPS_AUTO)
+
+endif # COMPILER_DEPEND
+
+endif # MOZ_AUTO_DEPS
+
+ifdef MOZ_MEMORY
+ifeq ($(OS_ARCH),SunOS)
+SOLARIS_JEMALLOC_LDFLAGS = $(call EXPAND_LIBNAME_PATH,jemalloc,$(DIST)/lib)
+endif
+endif
+
+# Rules for building native targets must come first because of the host_ prefix
+host_%.$(OBJ_SUFFIX): %.c Makefile Makefile.in
+	$(REPORT_BUILD)
+	$(ELOG) $(HOST_CC) $(HOST_OUTOPTION)$@ -c $(HOST_CFLAGS) $(INCLUDES) $(NSPR_CFLAGS) $(_VPATH_SRCS)
+
+host_%.$(OBJ_SUFFIX): %.cpp Makefile Makefile.in
+	$(REPORT_BUILD)
+	$(ELOG) $(HOST_CXX) $(HOST_OUTOPTION)$@ -c $(HOST_CXXFLAGS) $(INCLUDES) $(NSPR_CFLAGS) $(_VPATH_SRCS)
+
+host_%.$(OBJ_SUFFIX): %.cc Makefile Makefile.in
+	$(REPORT_BUILD)
+	$(ELOG) $(HOST_CXX) $(HOST_OUTOPTION)$@ -c $(HOST_CXXFLAGS) $(INCLUDES) $(NSPR_CFLAGS) $(_VPATH_SRCS)
+
+host_%.$(OBJ_SUFFIX): %.m Makefile Makefile.in
+	$(REPORT_BUILD)
+	$(ELOG) $(HOST_CC) $(HOST_OUTOPTION)$@ -c $(HOST_CFLAGS) $(HOST_CMFLAGS) $(INCLUDES) $(NSPR_CFLAGS) $(_VPATH_SRCS)
+
+host_%.$(OBJ_SUFFIX): %.mm Makefile Makefile.in
+	$(REPORT_BUILD)
+	$(ELOG) $(HOST_CXX) $(HOST_OUTOPTION)$@ -c $(HOST_CXXFLAGS) $(HOST_CMMFLAGS) $(INCLUDES) $(NSPR_CFLAGS) $(_VPATH_SRCS)
+
+%: %.c Makefile Makefile.in
+	$(REPORT_BUILD)
+	@$(MAKE_DEPS_AUTO_CC)
+	$(ELOG) $(CC) $(CFLAGS) $(LDFLAGS) $(OUTOPTION)$@ $(_VPATH_SRCS)
+
+%.$(OBJ_SUFFIX): %.c Makefile Makefile.in
+	$(REPORT_BUILD)
+	@$(MAKE_DEPS_AUTO_CC)
+	$(ELOG) $(CC) $(OUTOPTION)$@ -c $(COMPILE_CFLAGS) $(_VPATH_SRCS)
+
+moc_%.cpp: %.h Makefile Makefile.in
+	$(MOC) $< $(OUTOPTION)$@ 
+
+ifdef ASFILES
+# The AS_DASH_C_FLAG is needed cause not all assemblers (Solaris) accept
+# a '-c' flag.
+%.$(OBJ_SUFFIX): %.$(ASM_SUFFIX) Makefile Makefile.in
+ifeq ($(MOZ_OS2_TOOLS),VACPP)
+	$(AS) -Fdo:./$(OBJDIR) -Feo:.$(OBJ_SUFFIX) $(ASFLAGS) $(AS_DASH_C_FLAG) $<
+else
+	$(AS) -o $@ $(ASFLAGS) $(AS_DASH_C_FLAG) $(_VPATH_SRCS)
+endif
+endif
+
+%.$(OBJ_SUFFIX): %.S Makefile Makefile.in
+	$(AS) -o $@ $(ASFLAGS) -c $<
+
+%: %.cpp Makefile Makefile.in
+	@$(MAKE_DEPS_AUTO_CXX)
+	$(CCC) $(OUTOPTION)$@ $(CXXFLAGS) $(_VPATH_SRCS) $(LDFLAGS)
+
+#
+# Please keep the next two rules in sync.
+#
+%.$(OBJ_SUFFIX): %.cc Makefile Makefile.in
+	$(REPORT_BUILD)
+	@$(MAKE_DEPS_AUTO_CXX)
+	$(ELOG) $(CCC) $(OUTOPTION)$@ -c $(COMPILE_CXXFLAGS) $(_VPATH_SRCS)
+
+%.$(OBJ_SUFFIX): %.cpp Makefile Makefile.in
+	$(REPORT_BUILD)
+	@$(MAKE_DEPS_AUTO_CXX)
+ifdef STRICT_CPLUSPLUS_SUFFIX
+	echo "#line 1 \"$*.cpp\"" | cat - $*.cpp > t_$*.cc
+	$(ELOG) $(CCC) -o $@ -c $(COMPILE_CXXFLAGS) t_$*.cc
+	rm -f t_$*.cc
+else
+	$(ELOG) $(CCC) $(OUTOPTION)$@ -c $(COMPILE_CXXFLAGS) $(_VPATH_SRCS)
+endif #STRICT_CPLUSPLUS_SUFFIX
+
+$(OBJ_PREFIX)%.$(OBJ_SUFFIX): %.mm Makefile Makefile.in
+	$(REPORT_BUILD)
+	@$(MAKE_DEPS_AUTO_CXX)
+	$(ELOG) $(CCC) -o $@ -c $(COMPILE_CXXFLAGS) $(COMPILE_CMMFLAGS) $(_VPATH_SRCS)
+
+$(OBJ_PREFIX)%.$(OBJ_SUFFIX): %.m Makefile Makefile.in
+	$(REPORT_BUILD)
+	@$(MAKE_DEPS_AUTO_CC)
+	$(ELOG) $(CC) -o $@ -c $(COMPILE_CFLAGS) $(COMPILE_CMFLAGS) $(_VPATH_SRCS)
+
+%.s: %.cpp
+	$(CCC) -S $(COMPILE_CXXFLAGS) $(_VPATH_SRCS)
+
+%.s: %.cc
+	$(CCC) -S $(COMPILE_CXXFLAGS) $(_VPATH_SRCS)
+
+%.s: %.c
+	$(CC) -S $(COMPILE_CFLAGS) $(_VPATH_SRCS)
+
+%.i: %.cpp
+	$(CCC) -C -E $(COMPILE_CXXFLAGS) $(_VPATH_SRCS) > $*.i
+
+%.i: %.cc
+	$(CCC) -C -E $(COMPILE_CXXFLAGS) $(_VPATH_SRCS) > $*.i
+
+%.i: %.c
+	$(CC) -C -E $(COMPILE_CFLAGS) $(_VPATH_SRCS) > $*.i
+
+%.i: %.mm
+	$(CCC) -C -E $(COMPILE_CXXFLAGS) $(COMPILE_CMMFLAGS) $(_VPATH_SRCS) > $*.i
+
+%.res: %.rc
+	@echo Creating Resource file: $@
+ifeq ($(OS_ARCH),OS2)
+	$(RC) $(RCFLAGS:-D%=-d %) -i $(subst /,\,$(srcdir)) -r $< $@
+else
+ifdef GNU_CC
+	$(RC) $(RCFLAGS) $(filter-out -U%,$(DEFINES)) $(INCLUDES:-I%=--include-dir %) $(OUTOPTION)$@ $(_VPATH_SRCS)
+else
+	$(RC) $(RCFLAGS) -r $(DEFINES) $(INCLUDES) $(OUTOPTION)$@ $(_VPATH_SRCS)
+endif
+endif
+
+# need 3 separate lines for OS/2
+%: %.pl
+	rm -f $@
+	cp $< $@
+	chmod +x $@
+
+%: %.sh
+	rm -f $@; cp $< $@; chmod +x $@
+
+# Cancel these implicit rules
+#
+%: %,v
+
+%: RCS/%,v
+
+%: s.%
+
+%: SCCS/s.%
+
+###############################################################################
+# Java rules
+###############################################################################
+ifneq (,$(filter OS2 WINNT WINCE,$(OS_ARCH)))
+SEP := ;
+else
+SEP := :
+endif
+
+EMPTY :=
+SPACE := $(EMPTY) $(EMPTY)
+
+# Cygwin and MSYS have their own special path form, but javac expects the source
+# and class paths to be in the DOS form (i.e. e:/builds/...).  This function
+# does the appropriate conversion on Windows, but is a noop on other systems.
+ifeq (,$(filter-out WINNT WINCE, $(HOST_OS_ARCH)))
+ifdef CYGWIN_WRAPPER
+normalizepath = $(foreach p,$(1),$(shell cygpath -m $(p)))
+else
+# assume MSYS
+#  We use 'pwd -W' to get DOS form of the path.  However, since the given path
+#  could be a file or a non-existent path, we cannot call 'pwd -W' directly
+#  on the path.  Instead, we extract the root path (i.e. "c:/"), call 'pwd -W'
+#  on it, then merge with the rest of the path.
+root-path = $(shell echo $(1) | sed -e "s|\(/[^/]*\)/\?\(.*\)|\1|")
+non-root-path = $(shell echo $(1) | sed -e "s|\(/[^/]*\)/\?\(.*\)|\2|")
+normalizepath = $(foreach p,$(1),$(if $(filter /%,$(1)),$(shell cd $(call root-path,$(1)) && pwd -W)$(call non-root-path,$(1)),$(1)))
+endif
+else
+normalizepath = $(1)
+endif
+
+_srcdir = $(call normalizepath,$(srcdir))
+ifdef JAVA_SOURCEPATH
+SP = $(subst $(SPACE),$(SEP),$(call normalizepath,$(strip $(JAVA_SOURCEPATH))))
+_JAVA_SOURCEPATH = ".$(SEP)$(_srcdir)$(SEP)$(SP)"
+else
+_JAVA_SOURCEPATH = ".$(SEP)$(_srcdir)"
+endif
+
+ifdef JAVA_CLASSPATH
+CP = $(subst $(SPACE),$(SEP),$(call normalizepath,$(strip $(JAVA_CLASSPATH))))
+_JAVA_CLASSPATH = ".$(SEP)$(CP)"
+else
+_JAVA_CLASSPATH = .
+endif
+
+_JAVA_DIR = _java
+$(_JAVA_DIR)::
+	$(NSINSTALL) -D $@
+
+$(_JAVA_DIR)/%.class: %.java Makefile Makefile.in $(_JAVA_DIR)
+	$(CYGWIN_WRAPPER) $(JAVAC) $(JAVAC_FLAGS) -classpath $(_JAVA_CLASSPATH) \
+			-sourcepath $(_JAVA_SOURCEPATH) -d $(_JAVA_DIR) $(_VPATH_SRCS)
+
+$(JAVA_LIBRARY): $(addprefix $(_JAVA_DIR)/,$(JAVA_SRCS:.java=.class)) Makefile Makefile.in
+	$(JAR) cf $@ -C $(_JAVA_DIR) .
+
+GARBAGE_DIRS += $(_JAVA_DIR)
+
+###############################################################################
+# Update Makefiles
+###############################################################################
+
+# In GNU make 3.80, makefiles must use the /cygdrive syntax, even if we're
+# processing them with AS perl. See bug 232003
+ifdef AS_PERL
+CYGWIN_TOPSRCDIR = -nowrap -p $(topsrcdir) -wrap
+endif
+
+# Note: Passing depth to make-makefile is optional.
+#       It saves the script some work, though.
+Makefile: Makefile.in
+	@$(PERL) $(AUTOCONF_TOOLS)/make-makefile -t $(topsrcdir) -d $(DEPTH) $(CYGWIN_TOPSRCDIR)
+
+ifdef SUBMAKEFILES
+# VPATH does not work on some machines in this case, so add $(srcdir)
+$(SUBMAKEFILES): % : $(srcdir)/%.in
+	$(PERL) $(AUTOCONF_TOOLS)/make-makefile -t $(topsrcdir) -d $(DEPTH) $(CYGWIN_TOPSRCDIR) $@
+endif
+
+ifdef AUTOUPDATE_CONFIGURE
+$(topsrcdir)/configure: $(topsrcdir)/configure.in
+	(cd $(topsrcdir) && $(AUTOCONF)) && (cd $(DEPTH) && ./config.status --recheck)
+endif
+
+###############################################################################
+# Bunch of things that extend the 'export' rule (in order):
+###############################################################################
+
+################################################################################
+# Copy each element of EXPORTS to $(PUBLIC)
+
+ifneq ($(EXPORTS)$(XPIDLSRCS)$(SDK_HEADERS)$(SDK_XPIDLSRCS),)
+$(SDK_PUBLIC) $(PUBLIC)::
+	@if test ! -d $@; then $(ECHO) Creating $@; rm -rf $@; $(NSINSTALL) -D $@; else true; fi
+endif
+
+ifdef MOZ_JAVAXPCOM
+ifneq ($(XPIDLSRCS)$(SDK_XPIDLSRCS),)
+$(JAVA_DIST_DIR)::
+	$(NSINSTALL) -D $@
+endif
+endif
+
+ifneq ($(XPI_NAME),)
+export::
+	@if test ! -d $(FINAL_TARGET); then echo Creating $(FINAL_TARGET); rm -fr $(FINAL_TARGET); $(NSINSTALL) -D $(FINAL_TARGET); else true; fi
+endif
+
+ifndef NO_DIST_INSTALL
+ifneq ($(EXPORTS),)
+export:: $(EXPORTS) $(PUBLIC)
+	$(INSTALL) $(IFLAGS1) $^
+endif 
+
+ifneq ($(SDK_HEADERS),)
+export:: $(SDK_HEADERS) $(SDK_PUBLIC)
+	$(INSTALL) $(IFLAGS1) $^
+
+export:: $(SDK_HEADERS) $(PUBLIC)
+	$(INSTALL) $(IFLAGS1) $^
+endif 
+endif # NO_DIST_INSTALL
+
+################################################################################
+# Copy each element of PREF_JS_EXPORTS
+
+ifdef GRE_MODULE
+PREF_DIR = greprefs
+else
+ifneq (,$(XPI_NAME)$(LIBXUL_SDK))
+PREF_DIR = defaults/preferences
+else
+PREF_DIR = defaults/pref
+endif
+endif
+
+ifneq ($(PREF_JS_EXPORTS),)
+# on win32, pref files need CRLF line endings... see bug 206029
+ifeq (WINNT,$(OS_ARCH))
+PREF_PPFLAGS = --line-endings=crlf
+endif
+
+ifndef NO_DIST_INSTALL
+libs:: $(PREF_JS_EXPORTS)
+	if test ! -d $(FINAL_TARGET)/$(PREF_DIR); then $(NSINSTALL) -D $(FINAL_TARGET)/$(PREF_DIR); fi
+	$(EXIT_ON_ERROR)  \
+	for i in $(PREF_JS_EXPORTS); do \
+	  dest=$(FINAL_TARGET)/$(PREF_DIR)/`basename $$i`; \
+	  $(RM) -f $$dest; \
+	  $(PYTHON) $(MOZILLA_SRCDIR)/config/Preprocessor.py $(PREF_PPFLAGS) $(DEFINES) $(ACDEFINES) $(XULPPFLAGS) $$i > $$dest; \
+	done
+endif
+endif
+
+################################################################################
+# Copy each element of AUTOCFG_JS_EXPORTS to $(FINAL_TARGET)/defaults/autoconfig
+
+ifneq ($(AUTOCFG_JS_EXPORTS),)
+$(FINAL_TARGET)/defaults/autoconfig::
+	@if test ! -d $@; then echo Creating $@; rm -rf $@; $(NSINSTALL) -D $@; else true; fi
+
+ifndef NO_DIST_INSTALL
+export:: $(AUTOCFG_JS_EXPORTS) $(FINAL_TARGET)/defaults/autoconfig
+	$(INSTALL) $(IFLAGS1) $^
+endif
+
+endif 
+################################################################################
+# Export the elements of $(XPIDLSRCS) & $(SDK_XPIDLSRCS), 
+# generating .h and .xpt files and moving them to the appropriate places.
+
+ifneq ($(XPIDLSRCS)$(SDK_XPIDLSRCS),)
+
+export:: $(patsubst %.idl,$(XPIDL_GEN_DIR)/%.h, $(XPIDLSRCS))
+
+ifndef XPIDL_MODULE
+XPIDL_MODULE		= $(MODULE)
+endif
+
+ifeq ($(XPIDL_MODULE),) # we need $(XPIDL_MODULE) to make $(XPIDL_MODULE).xpt
+export:: FORCE
+	@echo
+	@echo "*** Error processing XPIDLSRCS:"
+	@echo "Please define MODULE or XPIDL_MODULE when defining XPIDLSRCS,"
+	@echo "so we have a module name to use when creating MODULE.xpt."
+	@echo; sleep 2; false
+endif
+
+$(SDK_IDL_DIR) $(IDL_DIR)::
+	@if test ! -d $@; then echo Creating $@; rm -rf $@; $(NSINSTALL) -D $@; else true; fi
+
+# generate .h files from into $(XPIDL_GEN_DIR), then export to $(PUBLIC);
+# warn against overriding existing .h file. 
+$(XPIDL_GEN_DIR)/.done:
+	@if test ! -d $(XPIDL_GEN_DIR); then echo Creating $(XPIDL_GEN_DIR)/.done; rm -rf $(XPIDL_GEN_DIR); mkdir $(XPIDL_GEN_DIR); fi
+	@touch $@
+
+# don't depend on $(XPIDL_GEN_DIR), because the modification date changes
+# with any addition to the directory, regenerating all .h files -> everything.
+
+$(XPIDL_GEN_DIR)/%.h: %.idl $(XPIDL_COMPILE) $(XPIDL_GEN_DIR)/.done
+	$(REPORT_BUILD)
+	$(ELOG) $(XPIDL_COMPILE) -m header -w $(XPIDL_FLAGS) -o $(XPIDL_GEN_DIR)/$* $(_VPATH_SRCS)
+	@if test -n "$(findstring $*.h, $(EXPORTS) $(SDK_HEADERS))"; \
+	  then echo "*** WARNING: file $*.h generated from $*.idl overrides $(srcdir)/$*.h"; else true; fi
+
+ifndef NO_GEN_XPT
+# generate intermediate .xpt files into $(XPIDL_GEN_DIR), then link
+# into $(XPIDL_MODULE).xpt and export it to $(FINAL_TARGET)/components.
+$(XPIDL_GEN_DIR)/%.xpt: %.idl $(XPIDL_COMPILE) $(XPIDL_GEN_DIR)/.done
+	$(REPORT_BUILD)
+	$(ELOG) $(XPIDL_COMPILE) -m typelib -w $(XPIDL_FLAGS) -e $@ -d $(MDDEPDIR)/$*.pp $(_VPATH_SRCS)
+
+# no need to link together if XPIDLSRCS contains only XPIDL_MODULE
+ifneq ($(XPIDL_MODULE).idl,$(strip $(XPIDLSRCS)))
+$(XPIDL_GEN_DIR)/$(XPIDL_MODULE).xpt: $(patsubst %.idl,$(XPIDL_GEN_DIR)/%.xpt,$(XPIDLSRCS) $(SDK_XPIDLSRCS)) Makefile.in Makefile $(XPIDL_LINK)
+	$(XPIDL_LINK) $(XPIDL_GEN_DIR)/$(XPIDL_MODULE).xpt $(patsubst %.idl,$(XPIDL_GEN_DIR)/%.xpt,$(XPIDLSRCS) $(SDK_XPIDLSRCS)) 
+endif # XPIDL_MODULE.xpt != XPIDLSRCS
+
+libs:: $(XPIDL_GEN_DIR)/$(XPIDL_MODULE).xpt
+ifndef NO_DIST_INSTALL
+	$(INSTALL) $(IFLAGS1) $(XPIDL_GEN_DIR)/$(XPIDL_MODULE).xpt $(FINAL_TARGET)/components
+endif
+
+endif # NO_GEN_XPT
+
+GARBAGE_DIRS		+= $(XPIDL_GEN_DIR)
+
+endif # XPIDLSRCS || SDK_XPIDLSRCS
+
+ifneq ($(XPIDLSRCS),)
+# export .idl files to $(IDL_DIR)
+ifndef NO_DIST_INSTALL
+export:: $(XPIDLSRCS) $(IDL_DIR)
+	$(INSTALL) $(IFLAGS1) $^
+
+export:: $(patsubst %.idl,$(XPIDL_GEN_DIR)/%.h, $(XPIDLSRCS)) $(PUBLIC)
+	$(INSTALL) $(IFLAGS1) $^ 
+endif # NO_DIST_INSTALL
+
+endif # XPIDLSRCS
+
+
+
+#
+# General rules for exporting idl files.
+#
+# WORK-AROUND ONLY, for mozilla/tools/module-deps/bootstrap.pl build.
+# Bug to fix idl dependency problems w/o this extra build pass is
+#   http://bugzilla.mozilla.org/show_bug.cgi?id=145777
+#
+$(IDL_DIR)::
+	@if test ! -d $@; then echo Creating $@; rm -rf $@; $(NSINSTALL) -D $@; else true; fi
+
+export-idl:: $(SUBMAKEFILES) $(MAKE_DIRS)
+
+ifneq ($(XPIDLSRCS)$(SDK_XPIDLSRCS),)
+ifndef NO_DIST_INSTALL
+export-idl:: $(XPIDLSRCS) $(SDK_XPIDLSRCS) $(IDL_DIR)
+	$(INSTALL) $(IFLAGS1) $^
+endif
+endif
+	+$(LOOP_OVER_DIRS)
+	+$(LOOP_OVER_TOOL_DIRS)
+
+
+
+
+ifneq ($(SDK_XPIDLSRCS),)
+# export .idl files to $(IDL_DIR) & $(SDK_IDL_DIR)
+ifndef NO_DIST_INSTALL
+export:: $(SDK_XPIDLSRCS) $(IDL_DIR)
+	$(INSTALL) $(IFLAGS1) $^
+
+export:: $(SDK_XPIDLSRCS) $(SDK_IDL_DIR)
+	$(INSTALL) $(IFLAGS1) $^
+
+export:: $(patsubst %.idl,$(XPIDL_GEN_DIR)/%.h, $(SDK_XPIDLSRCS)) $(PUBLIC)
+	$(INSTALL) $(IFLAGS1) $^
+
+export:: $(patsubst %.idl,$(XPIDL_GEN_DIR)/%.h, $(SDK_XPIDLSRCS)) $(SDK_PUBLIC)
+	$(INSTALL) $(IFLAGS1) $^
+endif
+
+endif # SDK_XPIDLSRCS
+
+
+
+ifdef MOZ_JAVAXPCOM
+ifneq ($(XPIDLSRCS)$(SDK_XPIDLSRCS),)
+
+JAVA_XPIDLSRCS = $(XPIDLSRCS) $(SDK_XPIDLSRCS)
+
+# A single IDL file can contain multiple interfaces, which result in multiple
+# Java interface files.  So use hidden dependency files.
+JAVADEPFILES = $(addprefix $(JAVA_GEN_DIR)/.,$(JAVA_XPIDLSRCS:.idl=.java.pp))
+
+$(JAVA_GEN_DIR):
+	$(NSINSTALL) -D $@
+GARBAGE_DIRS += $(JAVA_GEN_DIR)
+
+# generate .java files into _javagen/[package name dirs]
+_JAVA_GEN_DIR = $(JAVA_GEN_DIR)/$(JAVA_IFACES_PKG_NAME)
+$(_JAVA_GEN_DIR):
+	$(NSINSTALL) -D $@
+
+$(JAVA_GEN_DIR)/.%.java.pp: %.idl $(XPIDL_COMPILE) $(_JAVA_GEN_DIR)
+	$(REPORT_BUILD)
+	$(ELOG) $(XPIDL_COMPILE) -m java -w -I$(srcdir) -I$(IDL_DIR) -o $(_JAVA_GEN_DIR)/$* $(_VPATH_SRCS)
+	@touch $@
+
+# "Install" generated Java interfaces.  We segregate them based on the XPI_NAME.
+# If XPI_NAME is not set, install into the "default" directory.
+ifneq ($(XPI_NAME),)
+JAVA_INSTALL_DIR = $(JAVA_DIST_DIR)/$(XPI_NAME)
+else
+JAVA_INSTALL_DIR = $(JAVA_DIST_DIR)/default
+endif
+
+$(JAVA_INSTALL_DIR):
+	$(NSINSTALL) -D $@
+
+export:: $(JAVA_DIST_DIR) $(JAVADEPFILES) $(JAVA_INSTALL_DIR)
+	(cd $(JAVA_GEN_DIR) && tar $(TAR_CREATE_FLAGS) - .) | (cd $(JAVA_INSTALL_DIR) && tar -xf -)
+
+endif # XPIDLSRCS || SDK_XPIDLSRCS
+endif # MOZ_JAVAXPCOM
+
+################################################################################
+# Copy each element of EXTRA_COMPONENTS to $(FINAL_TARGET)/components
+ifdef EXTRA_COMPONENTS
+libs:: $(EXTRA_COMPONENTS)
+ifndef NO_DIST_INSTALL
+	$(INSTALL) $(IFLAGS1) $^ $(FINAL_TARGET)/components
+endif
+
+endif
+
+ifdef EXTRA_PP_COMPONENTS
+libs:: $(EXTRA_PP_COMPONENTS)
+ifndef NO_DIST_INSTALL
+	$(EXIT_ON_ERROR) \
+	$(NSINSTALL) -D $(FINAL_TARGET)/components; \
+	for i in $^; do \
+	  dest=$(FINAL_TARGET)/components/`basename $$i`; \
+	  $(RM) -f $$dest; \
+	  $(PYTHON) $(MOZILLA_SRCDIR)/config/Preprocessor.py $(DEFINES) $(ACDEFINES) $(XULPPFLAGS) $$i > $$dest; \
+	done
+endif
+
+endif
+
+################################################################################
+# Copy each element of EXTRA_JS_MODULES to $(FINAL_TARGET)/modules
+ifdef EXTRA_JS_MODULES
+libs:: $(EXTRA_JS_MODULES)
+ifndef NO_DIST_INSTALL
+	$(INSTALL) $(IFLAGS1) $^ $(FINAL_TARGET)/modules
+endif
+
+endif
+
+ifdef EXTRA_PP_JS_MODULES
+libs:: $(EXTRA_PP_JS_MODULES)
+ifndef NO_DIST_INSTALL
+	$(EXIT_ON_ERROR) \
+	$(NSINSTALL) -D $(FINAL_TARGET)/modules; \
+	for i in $^; do \
+	  dest=$(FINAL_TARGET)/modules/`basename $$i`; \
+	  $(RM) -f $$dest; \
+	  $(PYTHON) $(MOZILLA_SRCDIR)/config/Preprocessor.py $(DEFINES) $(ACDEFINES) $(XULPPFLAGS) $$i > $$dest; \
+	done
+endif
+
+endif
+
+################################################################################
+# SDK
+
+ifneq (,$(SDK_LIBRARY))
+$(SDK_LIB_DIR)::
+	@if test ! -d $@; then echo Creating $@; rm -rf $@; $(NSINSTALL) -D $@; else true; fi
+
+ifndef NO_DIST_INSTALL
+libs:: $(SDK_LIBRARY) $(SDK_LIB_DIR)
+	$(INSTALL) $(IFLAGS2) $^
+endif
+
+endif # SDK_LIBRARY
+
+ifneq (,$(SDK_BINARY))
+$(SDK_BIN_DIR)::
+	@if test ! -d $@; then echo Creating $@; rm -rf $@; $(NSINSTALL) -D $@; else true; fi
+
+ifndef NO_DIST_INSTALL
+libs:: $(SDK_BINARY) $(SDK_BIN_DIR)
+	$(INSTALL) $(IFLAGS2) $^
+endif
+
+endif # SDK_BINARY
+
+################################################################################
+# CHROME PACKAGING
+
+JAR_MANIFEST := $(srcdir)/jar.mn
+
+chrome::
+	$(MAKE) realchrome
+	+$(LOOP_OVER_DIRS)
+	+$(LOOP_OVER_TOOL_DIRS)
+
+libs realchrome:: $(CHROME_DEPS)
+ifndef NO_DIST_INSTALL
+	@$(EXIT_ON_ERROR) \
+	if test -f $(JAR_MANIFEST); then \
+	  if test ! -d $(FINAL_TARGET)/chrome; then $(NSINSTALL) -D $(FINAL_TARGET)/chrome; fi; \
+	  if test ! -d $(MAKE_JARS_TARGET)/chrome; then $(NSINSTALL) -D $(MAKE_JARS_TARGET)/chrome; fi; \
+	  $(PYTHON) $(MOZILLA_DIR)/config/Preprocessor.py $(XULPPFLAGS) $(DEFINES) $(ACDEFINES) \
+	    $(JAR_MANIFEST) | \
+	  $(PERL) -I$(MOZILLA_DIR)/config $(MOZILLA_DIR)/config/make-jars.pl \
+	    $(QUIET) -d $(MAKE_JARS_TARGET)/chrome -j $(FINAL_TARGET)/chrome \
+	    $(MAKE_JARS_FLAGS) -- "$(XULPPFLAGS) $(DEFINES) $(ACDEFINES)"; \
+	fi
+endif
+
+ifneq ($(DIST_FILES),)
+libs:: $(DIST_FILES)
+	@$(EXIT_ON_ERROR) \
+	for f in $(DIST_FILES); do \
+	  dest=$(FINAL_TARGET)/`basename $$f`; \
+	  $(RM) -f $$dest; \
+	  $(PYTHON) $(MOZILLA_DIR)/config/Preprocessor.py \
+	    $(XULAPP_DEFINES) $(DEFINES) $(ACDEFINES) $(XULPPFLAGS) \
+	    $(srcdir)/$$f > $$dest; \
+	done
+endif
+
+ifneq ($(DIST_CHROME_FILES),)
+libs:: $(DIST_CHROME_FILES)
+	@$(EXIT_ON_ERROR) \
+	for f in $(DIST_CHROME_FILES); do \
+	  dest=$(FINAL_TARGET)/chrome/`basename $$f`; \
+	  $(RM) -f $$dest; \
+	  $(PYTHON) $(MOZILLA_DIR)/config/Preprocessor.py \
+	    $(XULAPP_DEFINES) $(DEFINES) $(ACDEFINES) $(XULPPFLAGS) \
+	    $(srcdir)/$$f > $$dest; \
+	done
+endif
+
+ifneq ($(XPI_PKGNAME),)
+libs realchrome::
+ifdef STRIP_XPI
+ifndef MOZ_DEBUG
+	@echo "Stripping $(XPI_PKGNAME) package directory..."
+	@echo $(FINAL_TARGET)
+	@cd $(FINAL_TARGET) && find . ! -type d \
+			! -name "*.js" \
+			! -name "*.xpt" \
+			! -name "*.gif" \
+			! -name "*.jpg" \
+			! -name "*.png" \
+			! -name "*.xpm" \
+			! -name "*.txt" \
+			! -name "*.rdf" \
+			! -name "*.sh" \
+			! -name "*.properties" \
+			! -name "*.dtd" \
+			! -name "*.html" \
+			! -name "*.xul" \
+			! -name "*.css" \
+			! -name "*.xml" \
+			! -name "*.jar" \
+			! -name "*.dat" \
+			! -name "*.tbl" \
+			! -name "*.src" \
+			! -name "*.reg" \
+			$(PLATFORM_EXCLUDE_LIST) \
+			-exec $(STRIP) $(STRIP_FLAGS) {} >/dev/null 2>&1 \;
+endif
+endif
+	@echo "Packaging $(XPI_PKGNAME).xpi..."
+	cd $(FINAL_TARGET) && $(ZIP) -qr ../$(XPI_PKGNAME).xpi *
+endif
+
+ifdef INSTALL_EXTENSION_ID
+ifndef XPI_NAME
+$(error XPI_NAME must be set for INSTALL_EXTENSION_ID)
+endif
+
+libs::
+	$(RM) -rf "$(DIST)/bin/extensions/$(INSTALL_EXTENSION_ID)"
+	$(NSINSTALL) -D "$(DIST)/bin/extensions/$(INSTALL_EXTENSION_ID)"
+	cd $(FINAL_TARGET) && tar $(TAR_CREATE_FLAGS) - . | (cd "../../bin/extensions/$(INSTALL_EXTENSION_ID)" && tar -xf -)
+
+endif
+
+ifneq (,$(filter flat symlink,$(MOZ_CHROME_FILE_FORMAT)))
+_JAR_REGCHROME_DISABLE_JAR=1
+else
+_JAR_REGCHROME_DISABLE_JAR=0
+endif
+
+REGCHROME = $(PERL) -I$(MOZILLA_DIR)/config $(MOZILLA_DIR)/config/add-chrome.pl \
+	$(if $(filter gtk2,$(MOZ_WIDGET_TOOLKIT)),-x) \
+	$(if $(CROSS_COMPILE),-o $(OS_ARCH)) $(FINAL_TARGET)/chrome/installed-chrome.txt \
+	$(_JAR_REGCHROME_DISABLE_JAR)
+
+REGCHROME_INSTALL = $(PERL) -I$(MOZILLA_DIR)/config $(MOZILLA_DIR)/config/add-chrome.pl \
+	$(if $(filter gtk2,$(MOZ_WIDGET_TOOLKIT)),-x) \
+	$(if $(CROSS_COMPILE),-o $(OS_ARCH)) $(DESTDIR)$(mozappdir)/chrome/installed-chrome.txt \
+	$(_JAR_REGCHROME_DISABLE_JAR)
+
+
+################################################################################
+# Testing frameworks support
+################################################################################
+
+ifdef ENABLE_TESTS
+
+ifdef XPCSHELL_TESTS
+ifndef MODULE
+$(error Must define MODULE when defining XPCSHELL_TESTS.)
+endif
+
+# Test file installation
+libs::
+	@$(EXIT_ON_ERROR) \
+	for testdir in $(XPCSHELL_TESTS); do \
+	  $(INSTALL) \
+	    $(srcdir)/$$testdir/*.js \
+	    $(MOZDEPTH)/_tests/xpcshell-simple/$(MODULE)/$$testdir; \
+	done
+
+# Path formats on Windows are hard.  We require a topsrcdir formatted so that
+# it may be passed to nsILocalFile.initWithPath (in other words, an absolute
+# path of the form X:\path\to\topsrcdir), which we store in NATIVE_TOPSRCDIR.
+# We require a forward-slashed path to topsrcdir so that it may be combined
+# with a relative forward-slashed path for loading scripts, both dynamically
+# and statically for head/test/tail JS files.  Of course, on non-Windows none
+# of this matters, and things will work correctly because everything's
+# forward-slashed, everywhere, always.
+ifdef CYGWIN_WRAPPER
+NATIVE_TOPSRCDIR   := `cygpath -wa $(MOZILLA_SRCDIR)`
+FWDSLASH_TOPSRCDIR := `cygpath -ma $(MOZILLA_SRCDIR)`
+else
+FWDSLASH_TOPSRCDIR := $(MOZILLA_SRCDIR)
+ifeq ($(HOST_OS_ARCH),WINNT)
+NATIVE_TOPSRCDIR   := $(subst /,\\,$(WIN_TOP_SRC)/mozilla)
+else 
+NATIVE_TOPSRCDIR   := $(MOZILLA_SRCDIR)
+endif
+endif # CYGWIN_WRAPPER
+
+# Test execution
+check::
+	@$(EXIT_ON_ERROR) \
+	for testdir in $(XPCSHELL_TESTS); do \
+	  $(RUN_TEST_PROGRAM) \
+	    $(MOZILLA_SRCDIR)/tools/test-harness/xpcshell-simple/test_all.sh \
+	      $(DIST)/bin/xpcshell \
+	      $(FWDSLASH_TOPSRCDIR) \
+	      $(NATIVE_TOPSRCDIR) \
+	      $(MOZDEPTH)/_tests/xpcshell-simple/$(MODULE)/$$testdir; \
+	done
+
+# Test execution
+check-interactive::
+	@$(EXIT_ON_ERROR) \
+	$(RUN_TEST_PROGRAM) \
+	  $(MOZILLA_SRCDIR)/tools/test-harness/xpcshell-simple/test_one.sh \
+	    $(DIST)/bin/xpcshell \
+	    $(FWDSLASH_TOPSRCDIR) \
+	    $(NATIVE_TOPSRCDIR) \
+	    $(MOZDEPTH)/_tests/xpcshell-simple/$(MODULE)/$$testdir \
+	    $(SOLO_FILE) 1;
+
+# Test execution
+check-one::
+	@$(EXIT_ON_ERROR) \
+	$(RUN_TEST_PROGRAM) \
+	  $(MOZILLA_SRCDIR)/tools/test-harness/xpcshell-simple/test_one.sh \
+	    $(DIST)/bin/xpcshell \
+	    $(FWDSLASH_TOPSRCDIR) \
+	    $(NATIVE_TOPSRCDIR) \
+	    $(MOZDEPTH)/_tests/xpcshell-simple/$(MODULE)/$$testdir \
+	    $(SOLO_FILE) 0;
+
+endif # XPCSHELL_TESTS
+
+endif # ENABLE_TESTS
+
+
+#############################################################################
+# Dependency system
+#############################################################################
+ifdef COMPILER_DEPEND
+depend::
+	@echo "$(MAKE): No need to run depend target.\
+			Using compiler-based depend." 1>&2
+ifeq ($(GNU_CC)$(GNU_CXX),)
+# Non-GNU compilers
+	@echo "`echo '$(MAKE):'|sed 's/./ /g'`"\
+	'(Compiler-based depend was turned on by "--enable-md".)' 1>&2
+else
+# GNU compilers
+	@space="`echo '$(MAKE): '|sed 's/./ /g'`";\
+	echo "$$space"'Since you are using a GNU compiler,\
+		it is on by default.' 1>&2; \
+	echo "$$space"'To turn it off, pass --disable-md to configure.' 1>&2
+endif
+
+else # ! COMPILER_DEPEND
+
+ifndef MOZ_AUTO_DEPS
+
+define MAKE_DEPS_NOAUTO
+	$(MKDEPEND) -w1024 -o'.$(OBJ_SUFFIX)' -f- $(DEFINES) $(ACDEFINES) $(INCLUDES) $< 2>/dev/null | sed -e "s|^[^ ]*/||" > $@
+endef
+
+$(MDDEPDIR)/%.pp: %.c
+	$(REPORT_BUILD)
+	@$(MAKE_DEPS_NOAUTO)
+
+$(MDDEPDIR)/%.pp: %.cpp
+	$(REPORT_BUILD)
+	@$(MAKE_DEPS_NOAUTO)
+
+$(MDDEPDIR)/%.pp: %.s
+	$(REPORT_BUILD)
+	@$(MAKE_DEPS_NOAUTO)
+
+ifneq (,$(OBJS)$(XPIDLSRCS)$(SDK_XPIDLSRCS)$(SIMPLE_PROGRAMS))
+depend:: $(SUBMAKEFILES) $(MAKE_DIRS) $(MDDEPFILES)
+else
+depend:: $(SUBMAKEFILES)
+endif
+	+$(LOOP_OVER_DIRS)
+	+$(LOOP_OVER_TOOL_DIRS)
+
+dependclean:: $(SUBMAKEFILES)
+	rm -f $(MDDEPFILES)
+	+$(LOOP_OVER_DIRS)
+	+$(LOOP_OVER_TOOL_DIRS)
+
+endif # MOZ_AUTO_DEPS
+
+endif # COMPILER_DEPEND
+
+
+#############################################################################
+# MDDEPDIR is the subdirectory where all the dependency files are placed.
+#   This uses a make rule (instead of a macro) to support parallel
+#   builds (-jN). If this were done in the LOOP_OVER_DIRS macro, two
+#   processes could simultaneously try to create the same directory.
+#
+$(MDDEPDIR):
+	@if test ! -d $@; then echo Creating $@; rm -rf $@; mkdir $@; else true; fi
+
+ifneq (,$(filter-out all chrome default export realchrome tools clean clobber clobber_all distclean realclean,$(MAKECMDGOALS)))
+ifneq (,$(OBJS)$(XPIDLSRCS)$(SDK_XPIDLSRCS)$(SIMPLE_PROGRAMS))
+MDDEPEND_FILES		:= $(strip $(wildcard $(MDDEPDIR)/*.pp))
+
+ifneq (,$(MDDEPEND_FILES))
+ifdef PERL
+# The script mddepend.pl checks the dependencies and writes to stdout
+# one rule to force out-of-date objects. For example,
+#   foo.o boo.o: FORCE
+# The script has an advantage over including the *.pp files directly
+# because it handles the case when header files are removed from the build.
+# 'make' would complain that there is no way to build missing headers.
+ifeq (,$(MAKE_RESTARTS))
+$(MDDEPDIR)/.all.pp: FORCE
+	@$(PERL) $(BUILD_TOOLS)/mddepend.pl $@ $(MDDEPEND_FILES)
+endif
+-include $(MDDEPDIR)/.all.pp
+else
+include $(MDDEPEND_FILES)
+endif
+endif
+
+endif
+endif
+#############################################################################
+
+-include $(topsrcdir)/$(MOZ_BUILD_APP)/app-rules.mk
+-include $(MY_RULES)
+
+#
+# This speeds up gmake's processing if these files don't exist.
+#
+$(MY_CONFIG) $(MY_RULES):
+	@touch $@
+
+#
+# Generate Emacs tags in a file named TAGS if ETAGS was set in $(MY_CONFIG)
+# or in $(MY_RULES)
+#
+ifdef ETAGS
+ifneq ($(CSRCS)$(CPPSRCS)$(HEADERS),)
+all:: TAGS
+TAGS:: $(CSRCS) $(CPPSRCS) $(HEADERS)
+	$(ETAGS) $(CSRCS) $(CPPSRCS) $(HEADERS)
+endif
+endif
+
+################################################################################
+# Special gmake rules.
+################################################################################
+
+
+#
+# Disallow parallel builds with MSVC < 8
+#
+ifneq (,$(filter 1200 1300 1310,$(_MSC_VER)))
+.NOTPARALLEL:
+endif
+
+#
+# Re-define the list of default suffixes, so gmake won't have to churn through
+# hundreds of built-in suffix rules for stuff we don't need.
+#
+.SUFFIXES:
+
+#
+# Fake targets.  Always run these rules, even if a file/directory with that
+# name already exists.
+#
+.PHONY: all all_platforms alltags boot checkout chrome realchrome clean clobber clobber_all export install libs makefiles realclean run_viewer run_apprunner tools $(DIRS) $(TOOL_DIRS) FORCE check check-interactive check-one
+
+# Used as a dependency to force targets to rebuild
+FORCE:
+
+# Delete target if error occurs when building target
+.DELETE_ON_ERROR:
+
+# Properly set LIBPATTERNS for the platform
+.LIBPATTERNS = $(if $(IMPORT_LIB_SUFFIX),$(LIB_PREFIX)%.$(IMPORT_LIB_SUFFIX)) $(LIB_PREFIX)%.$(LIB_SUFFIX) $(DLL_PREFIX)%$(DLL_SUFFIX) 
+
+tags: TAGS
+
+TAGS: $(SUBMAKEFILES) $(CSRCS) $(CPPSRCS) $(wildcard *.h)
+	-etags $(CSRCS) $(CPPSRCS) $(wildcard *.h)
+	+$(LOOP_OVER_DIRS)
+
+echo-variable-%:
+	@echo $($*)
+
+echo-tiers:
+	@echo $(TIERS)
+
+echo-dirs:
+	@echo $(DIRS)
+
+echo-module:
+	@echo $(MODULE)
+
+echo-requires:
+	@echo $(REQUIRES)
+
+echo-requires-recursive::
+ifdef _REPORT_ALL_DIRS
+	@echo $(subst $(topsrcdir)/,,$(srcdir)): $(MODULE): $(REQUIRES)
+else
+	@$(if $(REQUIRES),echo $(subst $(topsrcdir)/,,$(srcdir)): $(MODULE): $(REQUIRES))
+endif
+	+$(LOOP_OVER_DIRS)
+
+echo-depth-path:
+	@$(MOZILLA_SRCDIR)/build/unix/print-depth-path.sh
+
+echo-module-name:
+	@$(MOZILLA_SRCDIR)/build/package/rpm/print-module-name.sh
+
+echo-module-filelist:
+	@$(MOZILLA_SRCDIR)/build/package/rpm/print-module-filelist.sh
+
+showtargs:
+ifneq (,$(filter $(PROGRAM) $(HOST_PROGRAM) $(SIMPLE_PROGRAMS) $(HOST_LIBRARY) $(LIBRARY) $(SHARED_LIBRARY),$(TARGETS)))
+	@echo --------------------------------------------------------------------------------
+	@echo "PROGRAM             = $(PROGRAM)"
+	@echo "SIMPLE_PROGRAMS     = $(SIMPLE_PROGRAMS)"
+	@echo "LIBRARY             = $(LIBRARY)"
+	@echo "SHARED_LIBRARY      = $(SHARED_LIBRARY)"
+	@echo "SHARED_LIBRARY_LIBS = $(SHARED_LIBRARY_LIBS)"
+	@echo "LIBS                = $(LIBS)"
+	@echo "DEF_FILE            = $(DEF_FILE)"
+	@echo "IMPORT_LIBRARY      = $(IMPORT_LIBRARY)"
+	@echo "STATIC_LIBS         = $(STATIC_LIBS)"
+	@echo "SHARED_LIBS         = $(SHARED_LIBS)"
+	@echo "EXTRA_DSO_LIBS      = $(EXTRA_DSO_LIBS)"
+	@echo "EXTRA_DSO_LDOPTS    = $(EXTRA_DSO_LDOPTS)"
+	@echo "DEPENDENT_LIBS      = $(DEPENDENT_LIBS)"
+	@echo --------------------------------------------------------------------------------
+endif
+	+$(LOOP_OVER_DIRS)
+
+showbuild:
+	@echo "MOZ_BUILD_ROOT     = $(MOZ_BUILD_ROOT)"
+	@echo "MOZ_WIDGET_TOOLKIT = $(MOZ_WIDGET_TOOLKIT)"
+	@echo "CC                 = $(CC)"
+	@echo "CXX                = $(CXX)"
+	@echo "CCC                = $(CCC)"
+	@echo "CPP                = $(CPP)"
+	@echo "LD                 = $(LD)"
+	@echo "AR                 = $(AR)"
+	@echo "IMPLIB             = $(IMPLIB)"
+	@echo "FILTER             = $(FILTER)"
+	@echo "MKSHLIB            = $(MKSHLIB)"
+	@echo "MKCSHLIB           = $(MKCSHLIB)"
+	@echo "RC                 = $(RC)"
+	@echo "CFLAGS             = $(CFLAGS)"
+	@echo "OS_CFLAGS          = $(OS_CFLAGS)"
+	@echo "COMPILE_CFLAGS     = $(COMPILE_CFLAGS)"
+	@echo "CXXFLAGS           = $(CXXFLAGS)"
+	@echo "OS_CXXFLAGS        = $(OS_CXXFLAGS)"
+	@echo "COMPILE_CXXFLAGS   = $(COMPILE_CXXFLAGS)"
+	@echo "COMPILE_CMFLAGS    = $(COMPILE_CMFLAGS)"
+	@echo "COMPILE_CMMFLAGS   = $(COMPILE_CMMFLAGS)"
+	@echo "LDFLAGS            = $(LDFLAGS)"
+	@echo "OS_LDFLAGS         = $(OS_LDFLAGS)"
+	@echo "DSO_LDOPTS         = $(DSO_LDOPTS)"
+	@echo "OS_INCLUDES        = $(OS_INCLUDES)"
+	@echo "OS_LIBS            = $(OS_LIBS)"
+	@echo "EXTRA_LIBS         = $(EXTRA_LIBS)"
+	@echo "BIN_FLAGS          = $(BIN_FLAGS)"
+	@echo "INCLUDES           = $(INCLUDES)"
+	@echo "DEFINES            = $(DEFINES)"
+	@echo "ACDEFINES          = $(ACDEFINES)"
+	@echo "BIN_SUFFIX         = $(BIN_SUFFIX)"
+	@echo "LIB_SUFFIX         = $(LIB_SUFFIX)"
+	@echo "DLL_SUFFIX         = $(DLL_SUFFIX)"
+	@echo "IMPORT_LIB_SUFFIX  = $(IMPORT_LIB_SUFFIX)"
+	@echo "INSTALL            = $(INSTALL)"
+
+showhost:
+	@echo "HOST_CC            = $(HOST_CC)"
+	@echo "HOST_CXX           = $(HOST_CXX)"
+	@echo "HOST_CFLAGS        = $(HOST_CFLAGS)"
+	@echo "HOST_LDFLAGS       = $(HOST_LDFLAGS)"
+	@echo "HOST_LIBS          = $(HOST_LIBS)"
+	@echo "HOST_EXTRA_LIBS    = $(HOST_EXTRA_LIBS)"
+	@echo "HOST_EXTRA_DEPS    = $(HOST_EXTRA_DEPS)"
+	@echo "HOST_PROGRAM       = $(HOST_PROGRAM)"
+	@echo "HOST_OBJS          = $(HOST_OBJS)"
+	@echo "HOST_PROGOBJS      = $(HOST_PROGOBJS)"
+	@echo "HOST_LIBRARY       = $(HOST_LIBRARY)"
+
+showbuildmods::
+	@echo "Build Modules	= $(BUILD_MODULES)"
+	@echo "Module dirs	= $(BUILD_MODULE_DIRS)"
+
+zipmakes:
+ifneq (,$(filter $(PROGRAM) $(SIMPLE_PROGRAMS) $(LIBRARY) $(SHARED_LIBRARY),$(TARGETS)))
+	zip $(DEPTH)/makefiles $(subst $(topsrcdir),$(MOZ_SRC)/mozilla,$(srcdir)/Makefile.in)
+endif
+	+$(LOOP_OVER_DIRS)
+
+documentation:
+	@cd $(DEPTH)
+	$(DOXYGEN) $(DEPTH)/config/doxygen.cfg
+
+check:: $(SUBMAKEFILES) $(MAKE_DIRS)
+	+$(LOOP_OVER_DIRS)
+	+$(LOOP_OVER_TOOL_DIRS)
new file mode 100644
--- /dev/null
+++ b/config/static-config.mk
@@ -0,0 +1,124 @@
+#
+# ***** BEGIN LICENSE BLOCK *****
+# Version: MPL 1.1/GPL 2.0/LGPL 2.1
+#
+# The contents of this file are subject to the Mozilla Public License Version
+# 1.1 (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+# http://www.mozilla.org/MPL/
+#
+# Software distributed under the License is distributed on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+# for the specific language governing rights and limitations under the
+# License.
+#
+# The Original Code is mozilla.org code.
+#
+# The Initial Developer of the Original Code is
+# Netscape Communications Corporation.
+# Portions created by the Initial Developer are Copyright (C) 1998
+# the Initial Developer. All Rights Reserved.
+#
+# Contributor(s):
+#
+# Alternatively, the contents of this file may be used under the terms of
+# either of the GNU General Public License Version 2 or later (the "GPL"),
+# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+# in which case the provisions of the GPL or the LGPL are applicable instead
+# of those above. If you wish to allow use of your version of this file only
+# under the terms of either the GPL or the LGPL, and not to allow others to
+# use your version of this file under the terms of the MPL, indicate your
+# decision by deleting the provisions above and replace them with the notice
+# and other provisions required by the GPL or the LGPL. If you do not delete
+# the provisions above, a recipient may use your version of this file under
+# the terms of any one of the MPL, the GPL or the LGPL.
+#
+# ***** END LICENSE BLOCK *****
+
+# Static components makefile
+# 	Include this makefile after config/config.mk & before config/rules.mk
+#	This makefile will provide the defines for statically linking
+#	all of the components into the binary.
+
+STATIC_CPPSRCS	+= nsStaticComponents.cpp
+STATIC_DEFINES	+= -D_BUILD_STATIC_BIN=1
+STATIC_REQUIRES += \
+	xpcom \
+	string \
+	$(NULL)
+
+STATIC_EXTRA_LIBS += \
+	$(addsuffix .$(LIB_SUFFIX),$(addprefix $(MOZDEPTH)/staticlib/components/$(LIB_PREFIX),$(shell cat $(FINAL_LINK_COMPS)))) \
+	$(addsuffix .$(LIB_SUFFIX),$(addprefix $(MOZDEPTH)/staticlib/$(LIB_PREFIX),$(shell cat $(FINAL_LINK_LIBS)))) \
+	$(NULL)
+
+STATIC_COMPONENT_LIST = $(shell cat $(FINAL_LINK_COMP_NAMES))
+
+STATIC_EXTRA_DEPS	+= $(FINAL_LINK_COMPS) $(FINAL_LINK_LIBS) $(addsuffix .$(LIB_SUFFIX),$(addprefix $(MOZDEPTH)/staticlib/components/$(LIB_PREFIX),$(shell cat $(FINAL_LINK_COMPS)))) $(addsuffix .$(LIB_SUFFIX),$(addprefix $(MOZDEPTH)/staticlib/$(LIB_PREFIX),$(shell cat $(FINAL_LINK_LIBS))))
+
+STATIC_EXTRA_DEPS	+= \
+	$(topsrcdir)/config/static-config.mk \
+	$(topsrcdir)/config/static-rules.mk \
+	$(NULL)
+
+ifdef MOZ_PSM
+STATIC_EXTRA_DEPS	+= $(NSS_DEP_LIBS)
+endif
+
+STATIC_EXTRA_LIBS	+= \
+		$(PNG_LIBS) \
+		$(JPEG_LIBS) \
+		$(ZLIB_LIBS) \
+		$(LCMS_LIBS) \
+		$(NULL)
+
+ifdef MOZ_PSM
+STATIC_EXTRA_LIBS	+= \
+		$(NSS_LIBS) \
+		$(NULL)
+endif
+
+ifdef MOZ_LDAP_XPCOM
+STATIC_EXTRA_LIBS	+= \
+		$(LDAP_LIBS) \
+		$(NULL)
+endif
+
+STATIC_EXTRA_LIBS	+= $(MOZ_CAIRO_LIBS)
+
+ifdef MOZ_ENABLE_GTK2
+STATIC_EXTRA_LIBS	+= $(XLDFLAGS) $(XT_LIBS) -lgthread-2.0
+STATIC_EXTRA_LIBS	+= $(MOZ_XFT_LIBS)
+STATIC_EXTRA_LIBS	+= $(MOZ_PANGO_LIBS)
+endif
+
+ifdef MOZ_STORAGE
+STATIC_EXTRA_LIBS	+= $(SQLITE_LIBS)
+endif
+
+ifdef MOZ_ENABLE_STARTUP_NOTIFICATION
+STATIC_EXTRA_LIBS	+= $(MOZ_STARTUP_NOTIFICATION_LIBS)
+endif
+
+# Component Makefile always brings in this.
+# STATIC_EXTRA_LIBS	+= $(TK_LIBS)
+
+# Some random modules require this
+ifndef MOZ_NO_XPCOM_OBSOLETE
+STATIC_EXTRA_LIBS	+= $(MOZ_XPCOM_OBSOLETE_LIBS)
+endif
+
+ifeq ($(OS_ARCH),WINNT)
+STATIC_EXTRA_LIBS += $(call EXPAND_LIBNAME,comctl32 comdlg32 uuid shell32 ole32 oleaut32 version winspool imm32)
+# XXX temporary workaround until link ordering issue is solved
+ifdef GNU_CC
+STATIC_EXTRA_LIBS += $(call EXPAND_LIBNAME,winmm wsock32 gdi32)
+endif
+STATIC_EXTRA_LIBS += $(call EXPAND_LIBNAME, usp10)
+endif
+
+ifeq ($(OS_ARCH),AIX)
+STATIC_EXTRA_LIBS += $(call EXPAND_LIBNAME,odm cfg)
+endif
+
+LOCAL_INCLUDES += -I$(topsrcdir)/config
new file mode 100644
--- /dev/null
+++ b/config/static-rules.mk
@@ -0,0 +1,25 @@
+
+ifdef _NO_AUTO_VARS
+_TARGET = $(srcdir)/$(@F)
+else
+_TARGET = $@
+endif
+
+$(warning FINAL_LINK_COMP_NAMES = $(FINAL_LINK_COMP_NAMES))
+$(warning FINAL_LINK_COMPS = $(FINAL_LINK_COMPS))
+
+nsStaticComponents.cpp: $(MOZILLA_SRCDIR)/config/nsStaticComponents.cpp.in Makefile Makefile.in $(FINAL_LINK_COMP_NAMES)
+	rm -f $@
+	cat $< | \
+	sed -e "s|%MODULE_LIST%|$(foreach m, $(STATIC_COMPONENT_LIST),MODULE($(m)))|" \
+	> $(_TARGET)
+
+GARBAGE += nsStaticComponents.cpp
+
+ifeq ($(OS_ARCH),IRIX)
+LDFLAGS	+= -Wl,-LD_LAYOUT:lgot_buffer=80
+endif
+
+ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
+LIBS	+= -framework QuickTime -framework IOKit -lcrypto
+endif
new file mode 100644
--- /dev/null
+++ b/config/version.mk
@@ -0,0 +1,85 @@
+# ***** BEGIN LICENSE BLOCK *****
+# Version: MPL 1.1/GPL 2.0/LGPL 2.1
+#
+# The contents of this file are subject to the Mozilla Public License Version
+# 1.1 (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+# http://www.mozilla.org/MPL/
+#
+# Software distributed under the License is distributed on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+# for the specific language governing rights and limitations under the
+# License.
+#
+# The Original Code is the Win32 Version System.
+#
+# The Initial Developer of the Original Code is Netscape Communications Corporation
+# Portions created by the Initial Developer are Copyright (C) 2002
+# the Initial Developer. All Rights Reserved.
+#
+# Contributor(s):
+#
+# Alternatively, the contents of this file may be used under the terms of
+# either the GNU General Public License Version 2 or later (the "GPL"), or
+# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+# in which case the provisions of the GPL or the LGPL are applicable instead
+# of those above. If you wish to allow use of your version of this file only
+# under the terms of either the GPL or the LGPL, and not to allow others to
+# use your version of this file under the terms of the MPL, indicate your
+# decision by deleting the provisions above and replace them with the notice
+# and other provisions required by the GPL or the LGPL. If you do not delete
+# the provisions above, a recipient may use your version of this file under
+# the terms of any one of the MPL, the GPL or the LGPL.
+#
+# ***** END LICENSE BLOCK *****
+
+ifndef INCLUDED_VERSION_MK
+INCLUDED_VERSION_MK=1
+
+# Windows gmake build:
+# Build default .rc file if $(RESFILE) isn't defined.
+# TODO:
+# PBI      : Private build info.  Not used currently.
+#            Guessing the best way would be to set an env var.
+# BINARY   : Binary name.  Not used currently.
+ifeq ($(MOZ_WIDGET_TOOLKIT),windows)
+ifndef RESFILE
+RCFILE=./module.rc
+RESFILE=./module.res
+_RC_STRING = -QUIET 1 -DEPTH $(MOZDEPTH) -TOPSRCDIR $(MOZILLA_SRCDIR) -BITS $(MOZ_BITS) -OBJDIR . -SRCDIR $(srcdir) -DISPNAME $(MOZ_APP_DISPLAYNAME)
+ifneq ($(BUILD_OFFICIAL)_$(MOZILLA_OFFICIAL),_)
+_RC_STRING += -OFFICIAL 1
+endif
+ifdef MOZ_DEBUG
+_RC_STRING += -DEBUG 1
+endif
+ifdef MODULE
+_RC_STRING += -MODNAME $(MODULE)
+endif
+ifdef PROGRAM
+_RC_STRING += -BINARY $(PROGRAM)
+else
+ifdef _PROGRAM
+_RC_STRING += -BINARY $(_PROGRAM)
+else
+ifdef SHARED_LIBRARY
+_RC_STRING += -BINARY $(SHARED_LIBRARY)
+endif
+endif
+endif
+ifdef RCINCLUDE
+_RC_STRING += -RCINCLUDE $(srcdir)/$(RCINCLUDE)
+endif
+
+GARBAGE += $(RESFILE) $(RCFILE)
+
+#dummy target so $(RCFILE) doesn't become the default =P
+all::
+
+$(RCFILE): $(RCINCLUDE) $(MOZILLA_SRCDIR)/config/version_win.pl
+	$(PERL) $(MOZILLA_SRCDIR)/config/version_win.pl $(_RC_STRING)
+
+endif  # RESFILE
+endif  # Windows
+
+endif
new file mode 100644
--- /dev/null
+++ b/configure.in
@@ -0,0 +1,7902 @@
+dnl -*- Mode: Autoconf; tab-width: 4; indent-tabs-mode: nil; -*-
+dnl vi: set tabstop=4 shiftwidth=4 expandtab:
+dnl ***** BEGIN LICENSE BLOCK *****
+dnl Version: MPL 1.1/GPL 2.0/LGPL 2.1
+dnl
+dnl The contents of this file are subject to the Mozilla Public License Version
+dnl 1.1 (the "License"); you may not use this file except in compliance with
+dnl the License. You may obtain a copy of the License at
+dnl http://www.mozilla.org/MPL/
+dnl
+dnl Software distributed under the License is distributed on an "AS IS" basis,
+dnl WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+dnl for the specific language governing rights and limitations under the
+dnl License.
+dnl
+dnl The Original Code is this file as it was released upon August 6, 1998.
+dnl
+dnl The Initial Developer of the Original Code is
+dnl Christopher Seawood.
+dnl Portions created by the Initial Developer are Copyright (C) 1998-2001
+dnl the Initial Developer. All Rights Reserved.
+dnl
+dnl Contributor(s):
+dnl   Jamie Zawinski <jwz@jwz.org>
+dnl   gettimeofday args check
+dnl   Christopher Blizzard <blizzard@appliedtheory.com>
+dnl   gnomefe update & enable-pthreads
+dnl   Ramiro Estrugo <ramiro@netscape.com>
+dnl   X11 makedepend support
+dnl   Insure support.
+dnl   Henry Sobotka <sobotka@axess.com>
+dnl   OS/2 support
+dnl   Dan Mosedale <dmose@mozilla.org>
+dnl   LDAP support
+dnl   Seth Spitzer <sspitzer@netscape.com>
+dnl   xpctools support
+dnl   Benjamin Smedberg <benjamin@smedbergs.us>
+dnl   Howard Chu <hyc@symas.com>
+dnl   MSYS support
+dnl   Mark Mentovai <mark@moxienet.com>:
+dnl   Mac OS X 10.4 support
+dnl   Giorgio Maone <g.maone@informaction.com>
+dnl   MSVC l10n compatible version check
+dnl   Ben Turner <mozilla@songbirdnest.com>
+dnl   comm-central adaptations
+dnl   Robert Kaiser <kairo@kairo.at>
+dnl
+dnl Alternatively, the contents of this file may be used under the terms of
+dnl either the GNU General Public License Version 2 or later (the "GPL"), or
+dnl the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+dnl in which case the provisions of the GPL or the LGPL are applicable instead
+dnl of those above. If you wish to allow use of your version of this file only
+dnl under the terms of either the GPL or the LGPL, and not to allow others to
+dnl use your version of this file under the terms of the MPL, indicate your
+dnl decision by deleting the provisions above and replace them with the notice
+dnl and other provisions required by the GPL or the LGPL. If you do not delete
+dnl the provisions above, a recipient may use your version of this file under
+dnl the terms of any one of the MPL, the GPL or the LGPL.
+dnl
+dnl ***** END LICENSE BLOCK *****
+
+dnl Process this file with autoconf to produce a configure script.
+dnl ========================================================
+
+AC_PREREQ(2.13)
+AC_INIT(config/config.mk)
+MOZILLA_SRCDIR=$topsrcdir/mozilla
+AC_CONFIG_AUX_DIR(${MOZILLA_SRCDIR}/build/autoconf)
+AC_CANONICAL_SYSTEM
+TARGET_CPU="${target_cpu}"
+TARGET_VENDOR="${target_vendor}"
+TARGET_OS="${target_os}"
+
+dnl comm-central-specific options
+dnl (MOZILLA_SRCDIR would fit here, but is needed to find autoconf tools)
+COMM_BUILD=1
+AC_SUBST(COMM_BUILD)
+AC_SUBST(MOZILLA_SRCDIR)
+dnl export this, so the var is set for mozilla/configure
+export MOZCONFIG=`$_AUTOCONF_TOOLS_DIR/mozconfig-find $topsrcdir`
+
+MOZ_DEB_TIMESTAMP=`date +"%a, %d  %b %Y %T %z"   2>&1` 
+AC_SUBST(MOZ_DEB_TIMESTAMP)
+
+
+dnl ========================================================
+dnl =
+dnl = Don't change the following two lines.  Doing so breaks:
+dnl =
+dnl = CFLAGS="-foo" ./configure
+dnl =
+dnl ========================================================
+CFLAGS="${CFLAGS=}"
+CPPFLAGS="${CPPFLAGS=}"
+CXXFLAGS="${CXXFLAGS=}"
+LDFLAGS="${LDFLAGS=}"
+HOST_CFLAGS="${HOST_CFLAGS=}"
+HOST_CXXFLAGS="${HOST_CXXFLAGS=}"
+HOST_LDFLAGS="${HOST_LDFLAGS=}"
+
+dnl ========================================================
+dnl = Preserve certain environment flags passed to configure
+dnl = We want sub projects to receive the same flags
+dnl = untainted by this configure script
+dnl ========================================================
+_SUBDIR_CC="$CC"
+_SUBDIR_CXX="$CXX"
+_SUBDIR_CFLAGS="$CFLAGS"
+_SUBDIR_CPPFLAGS="$CPPFLAGS"
+_SUBDIR_CXXFLAGS="$CXXFLAGS"
+_SUBDIR_LDFLAGS="$LDFLAGS"
+_SUBDIR_HOST_CC="$HOST_CC"
+_SUBDIR_HOST_CFLAGS="$HOST_CFLAGS"
+_SUBDIR_HOST_CXXFLAGS="$HOST_CXXFLAGS"
+_SUBDIR_HOST_LDFLAGS="$HOST_LDFLAGS"
+_SUBDIR_CONFIG_ARGS="$ac_configure_args"
+
+dnl Set the version number of the libs included with mozilla
+dnl ========================================================
+MOZJPEG=62
+MOZPNG=10217
+MOZZLIB=0x1230
+NSPR_VERSION=4
+NSS_VERSION=3
+
+dnl Set the minimum version of toolkit libs used by mozilla
+dnl ========================================================
+GLIB_VERSION=1.2.0
+LIBIDL_VERSION=0.6.3
+PERL_VERSION=5.006
+LIBART_VERSION=2.3.4
+CAIRO_VERSION=1.6.0
+GLITZ_VERSION=0.4.0
+PANGO_VERSION=1.10.0
+GTK2_VERSION=2.10.0
+MAKE_VERSION=3.78
+WINDRES_VERSION=2.14.90
+W32API_VERSION=3.8
+GNOMEVFS_VERSION=2.0
+GNOMEUI_VERSION=2.2.0
+GCONF_VERSION=1.2.1
+LIBGNOME_VERSION=2.0
+STARTUP_NOTIFICATION_VERSION=0.8
+DBUS_VERSION=0.60
+LCMS_VERSION=1.17
+SQLITE_VERSION=3.5.4
+
+MSMANIFEST_TOOL=
+
+dnl Set various checks
+dnl ========================================================
+MISSING_X=
+AC_PROG_AWK
+
+dnl Initialize the Pthread test variables early so they can be
+dnl  overridden by each platform.
+dnl ========================================================
+USE_PTHREADS=
+_PTHREAD_LDFLAGS=""
+
+dnl Do not allow a separate objdir build if a srcdir build exists.
+dnl ==============================================================
+_topsrcdir=`cd \`dirname $0\`; pwd`
+_objdir=`pwd`
+
+if test "$_topsrcdir" != "$_objdir"
+then
+  # Check for a couple representative files in the source tree
+  _conflict_files=
+  for file in $_topsrcdir/Makefile $_topsrcdir/config/autoconf.mk; do
+    if test -f $file; then
+      _conflict_files="$_conflict_files $file"
+    fi
+  done
+  if test "$_conflict_files"; then
+    echo "***"
+    echo "*   Your source tree contains these files:"
+    for file in $_conflict_files; do
+      echo "*         $file"
+    done
+    cat 1>&2 <<-EOF
+	*   This indicates that you previously built in the source tree.
+	*   A source tree build can confuse the separate objdir build.
+	*
+	*   To clean up the source tree:
+	*     1. cd $_topsrcdir
+	*     2. gmake distclean
+	***
+	EOF
+    exit 1
+    break
+  fi
+fi
+MOZ_BUILD_ROOT=`pwd`
+
+dnl Default to MSVC for win32
+dnl ==============================================================
+if test -z "$CROSS_COMPILE"; then
+case "$target" in
+*-cygwin*|*-mingw*|*-msvc*|*-mks*)
+    MAKE_VERSION=3.79
+    if test -z "$CC"; then CC=cl; fi
+    if test -z "$CXX"; then CXX=cl; fi
+    if test -z "$CPP"; then CPP="cl -E -nologo"; fi
+    if test -z "$CXXCPP"; then CXXCPP="cl -TP -E -nologo"; ac_cv_prog_CXXCPP="$CXXCPP"; fi
+    if test -z "$LD"; then LD=link; fi
+    if test -z "$AS"; then AS=ml; fi
+    if test -z "$MIDL"; then MIDL=midl; fi
+    ;;
+esac
+fi
+
+COMPILE_ENVIRONMENT=1
+MOZ_ARG_ENABLE_BOOL(compile-environment,
+[  --disable-compile-environment
+                           Disable compiler/library checks.],
+    COMPILE_ENVIRONMENT=1,
+    COMPILE_ENVIRONMENT= )
+
+dnl ========================================================
+dnl Checks for compilers.
+dnl ========================================================
+dnl Set CROSS_COMPILE in the environment when running configure
+dnl to use the cross-compile setup for now
+dnl ========================================================
+
+if test "$COMPILE_ENVIRONMENT"; then
+
+dnl Do some special WinCE toolchain stuff
+case "$target" in
+*wince)
+    echo -----------------------------------------------------------------------------
+    echo Building Windows CE Shunt Library and Tool Chain
+    echo -----------------------------------------------------------------------------
+
+    ac_exeext=.exe
+
+    echo -n "#define TOPSRCDIR \"" > $srcdir/build/wince/tools/topsrcdir.h
+    echo `cd "$_topsrcdir" && pwd -W | tr '\n' '\"'` >> $srcdir/build/wince/tools/topsrcdir.h
+    make -C $srcdir/build/wince/tools
+    echo -----------------------------------------------------------------------------
+    ;;
+esac
+
+if test -n "$CROSS_COMPILE" && test "$target" != "$host"; then
+    echo "cross compiling from $host to $target"
+    cross_compiling=yes
+
+    _SAVE_CC="$CC"
+    _SAVE_CFLAGS="$CFLAGS"
+    _SAVE_LDFLAGS="$LDFLAGS"
+
+    AC_MSG_CHECKING([for host c compiler])
+    AC_CHECK_PROGS(HOST_CC, $HOST_CC gcc cc /usr/ucb/cc cl icc, "")
+    if test -z "$HOST_CC"; then
+        AC_MSG_ERROR([no acceptable c compiler found in \$PATH])
+    fi
+    AC_MSG_RESULT([$HOST_CC])
+    AC_MSG_CHECKING([for host c++ compiler])
+    AC_CHECK_PROGS(HOST_CXX, $HOST_CXX $CCC c++ g++ gcc CC cxx cc++ cl icc, "")
+    if test -z "$HOST_CXX"; then
+        AC_MSG_ERROR([no acceptable c++ compiler found in \$PATH])
+    fi
+    AC_MSG_RESULT([$HOST_CXX])
+
+    if test -z "$HOST_CFLAGS"; then
+        HOST_CFLAGS="$CFLAGS"
+    fi
+    if test -z "$HOST_CXXFLAGS"; then
+        HOST_CXXFLAGS="$CXXFLAGS"
+    fi
+    if test -z "$HOST_LDFLAGS"; then
+        HOST_LDFLAGS="$LDFLAGS"
+    fi
+    AC_CHECK_PROGS(HOST_RANLIB, $HOST_RANLIB ranlib, ranlib, :)
+    AC_CHECK_PROGS(HOST_AR, $HOST_AR ar, ar, :)
+    CC="$HOST_CC"
+    CFLAGS="$HOST_CFLAGS"
+    LDFLAGS="$HOST_LDFLAGS"
+
+    AC_MSG_CHECKING([whether the host c compiler ($HOST_CC $HOST_CFLAGS $HOST_LDFLAGS) works])
+    AC_TRY_COMPILE([], [return(0);], 
+	[ac_cv_prog_hostcc_works=1 AC_MSG_RESULT([yes])],
+	AC_MSG_ERROR([installation or configuration problem: host compiler $HOST_CC cannot create executables.]) )
+
+    CC="$HOST_CXX"
+    CFLAGS="$HOST_CXXFLAGS"
+
+    AC_MSG_CHECKING([whether the host c++ compiler ($HOST_CXX $HOST_CXXFLAGS $HOST_LDFLAGS) works])
+    AC_TRY_COMPILE([], [return(0);], 
+	[ac_cv_prog_hostcxx_works=1 AC_MSG_RESULT([yes])],
+	AC_MSG_ERROR([installation or configuration problem: host compiler $HOST_CXX cannot create executables.]) )
+    
+    CC=$_SAVE_CC
+    CFLAGS=$_SAVE_CFLAGS
+    LDFLAGS=$_SAVE_LDFLAGS
+
+    case "$build:$target" in
+      powerpc-apple-darwin8*:i?86-apple-darwin*)
+        dnl The Darwin cross compiler doesn't necessarily point itself at a
+        dnl root that has libraries for the proper architecture, it defaults
+        dnl to the system root.  The libraries in the system root on current
+        dnl versions of PPC OS X 10.4 aren't fat, so these target compiler
+        dnl checks will fail.  Fake a working SDK in that case.
+        _SAVE_CFLAGS=$CFLAGS
+        _SAVE_CXXFLAGS=$CXXLAGS
+        CFLAGS="-isysroot /Developer/SDKs/MacOSX10.4u.sdk $CFLAGS"
+        CXXFLAGS="-isysroot /Developer/SDKs/MacOSX10.4u.sdk $CXXFLAGS"
+        ;;
+    esac
+
+    AC_CHECK_PROGS(CC, $CC "${target_alias}-gcc" "${target}-gcc", :)
+    unset ac_cv_prog_CC
+    AC_PROG_CC
+    AC_CHECK_PROGS(CXX, $CXX "${target_alias}-g++" "${target}-g++", :)
+    unset ac_cv_prog_CXX
+    AC_PROG_CXX
+
+    case "$build:$target" in
+      powerpc-apple-darwin8*:i?86-apple-darwin*)
+        dnl Revert the changes made above.  From this point on, the target
+        dnl compiler will never be used without applying the SDK to CFLAGS
+        dnl (see --with-macos-sdk below).
+        CFLAGS=$_SAVE_CFLAGS
+        CXXFLAGS=$_SAVE_CXXFLAGS
+        ;;
+    esac
+
+    AC_CHECK_PROGS(RANLIB, $RANLIB "${target_alias}-ranlib" "${target}-ranlib", :)
+    AC_CHECK_PROGS(AR, $AR "${target_alias}-ar" "${target}-ar", :)
+    AC_PATH_PROGS(AS, $AS "${target_alias}-as" "${target}-as", :)
+    AC_CHECK_PROGS(LD, $LD "${target_alias}-ld" "${target}-ld", :)
+    AC_CHECK_PROGS(STRIP, $STRIP "${target_alias}-strip" "${target}-strip", :)
+    AC_CHECK_PROGS(WINDRES, $WINDRES "${target_alias}-windres" "${target}-windres", :)
+    AC_DEFINE(CROSS_COMPILE)
+else
+    AC_PROG_CC
+    AC_PROG_CXX
+    AC_PROG_RANLIB
+    AC_PATH_PROGS(AS, $AS as, $CC)
+    AC_CHECK_PROGS(AR, ar, :)
+    AC_CHECK_PROGS(LD, ld, :)
+    AC_CHECK_PROGS(STRIP, strip, :)
+    AC_CHECK_PROGS(WINDRES, windres, :)
+    if test -z "$HOST_CC"; then
+        HOST_CC="$CC"
+    fi
+    if test -z "$HOST_CFLAGS"; then
+        HOST_CFLAGS="$CFLAGS"
+    fi
+    if test -z "$HOST_CXX"; then
+        HOST_CXX="$CXX"
+    fi
+    if test -z "$HOST_CXXFLAGS"; then
+        HOST_CXXFLAGS="$CXXFLAGS"
+    fi
+    if test -z "$HOST_LDFLAGS"; then
+        HOST_LDFLAGS="$LDFLAGS"
+    fi
+    if test -z "$HOST_RANLIB"; then
+        HOST_RANLIB="$RANLIB"
+    fi
+    if test -z "$HOST_AR"; then
+       HOST_AR="$AR"
+    fi
+fi
+
+GNU_AS=
+GNU_LD=
+GNU_CC=
+GNU_CXX=
+CC_VERSION='N/A'
+CXX_VERSION='N/A'
+if test "$GCC" = "yes"; then
+    GNU_CC=1
+    CC_VERSION=`$CC -v 2>&1 | grep 'gcc version'`
+fi
+if test "$GXX" = "yes"; then
+    GNU_CXX=1
+    CXX_VERSION=`$CXX -v 2>&1 | grep 'gcc version'`
+fi
+if test "`echo | $AS -v 2>&1 | grep -c GNU`" != "0"; then
+    GNU_AS=1
+fi
+if test "`echo | $LD -v 2>&1 | grep -c GNU`" != "0"; then
+    GNU_LD=1
+fi
+if test "$GNU_CC"; then
+    if `$CC -print-prog-name=ld` -v 2>&1 | grep -c GNU >/dev/null; then
+        GCC_USE_GNU_LD=1
+    fi
+fi
+
+INTEL_CC=
+INTEL_CXX=
+if test "$GCC" = yes; then
+   if test "`$CC -help 2>&1 | grep -c 'Intel(R) C Compiler'`" != "0"; then
+     INTEL_CC=1
+   fi
+fi
+
+if test "$GXX" = yes; then
+   if test "`$CXX -help 2>&1 | grep -c 'Intel(R) C++ Compiler'`" != "0"; then
+     INTEL_CXX=1
+   fi
+fi
+
+dnl Special win32 checks
+dnl ========================================================
+case "$target" in
+*-wince)
+    WINVER=500
+    ;;
+*)
+    if test -n "$GNU_CC"; then  
+        WINVER=501
+    else    
+        WINVER=500
+    fi
+    ;;
+esac
+
+MOZ_ARG_WITH_STRING(windows-version,
+[  --with-windows-version=WINVER
+                          Minimum Windows version (WINVER) to support
+                              400: Windows 95
+                              500: Windows 2000
+                              501: Windows XP],
+  WINVER=$withval)
+
+case "$WINVER" in
+400|500|501)
+    ;;
+
+*)
+    AC_MSG_ERROR([Invalid value --with-windows-version, must be 400, 500 or 501]);
+    ;;
+
+esac
+
+case "$target" in
+*-cygwin*|*-mingw*|*-msvc*|*-mks*|*-wince)
+    if test "$GCC" != "yes"; then
+        # Check to see if we are really running in a msvc environemnt
+        _WIN32_MSVC=1
+        AC_CHECK_PROGS(MIDL, midl)
+
+        # Make sure compilers are valid
+        CFLAGS="$CFLAGS -TC -nologo"
+        CXXFLAGS="$CXXFLAGS -TP -nologo"
+        AC_LANG_SAVE
+        AC_LANG_C
+        AC_TRY_COMPILE([#include <stdio.h>],
+            [ printf("Hello World\n"); ],,
+            AC_MSG_ERROR([\$(CC) test failed.  You must have MS VC++ in your path to build.]) )
+
+        AC_LANG_CPLUSPLUS
+        AC_TRY_COMPILE([#include <new.h>],
+            [ unsigned *test = new unsigned(42); ],,
+            AC_MSG_ERROR([\$(CXX) test failed.  You must have MS VC++ in your path to build.]) )
+        AC_LANG_RESTORE
+        
+        changequote(,)
+        _MSVC_VER_FILTER='s|.* ([0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?).*|\1|p'
+        changequote([,])
+        
+        # Determine compiler version
+        CC_VERSION=`"${CC}" -v 2>&1 | sed -nre "$_MSVC_VER_FILTER"`
+        _CC_MAJOR_VERSION=`echo ${CC_VERSION} | $AWK -F\. '{ print $1 }'`
+        _CC_MINOR_VERSION=`echo ${CC_VERSION} | $AWK -F\. '{ print $2 }'`
+        _CC_RELEASE=`echo ${CC_VERSION} | $AWK -F\. '{ print $3 }'`
+        _CC_BUILD=`echo ${CC_VERSION} | $AWK -F\. '{ print $4 }'`
+        _MSC_VER=${_CC_MAJOR_VERSION}${_CC_MINOR_VERSION}
+
+        CXX_VERSION=`"${CXX}" -v 2>&1 | sed -nre "$_MSVC_VER_FILTER"`
+        _CXX_MAJOR_VERSION=`echo ${CXX_VERSION} | $AWK -F\. '{ print $1 }'`
+
+        if test "$_CC_MAJOR_VERSION" != "$_CXX_MAJOR_VERSION"; then
+            AC_MSG_ERROR([The major versions of \$CC and \$CXX do not match.])
+        fi
+        if test "$_CC_MAJOR_VERSION" = "12"; then
+            _CC_SUITE=6
+        elif test "$_CC_MAJOR_VERSION" = "13"; then
+            _CC_SUITE=7
+        elif test "$_CC_MAJOR_VERSION" = "14"; then
+            _CC_SUITE=8
+            CXXFLAGS="$CXXFLAGS -Zc:wchar_t-"
+            dnl -DYNAMICBASE is only supported on VC8SP1 or newer,
+            dnl so be very specific here!
+            dnl VC8 is 14.00.50727.42, VC8SP1 is 14.00.50727.762
+            if test $_CC_RELEASE -gt 50727; then
+               _USE_DYNAMICBASE=1
+            elif test $_CC_BUILD -ge 762; then
+               _USE_DYNAMICBASE=1
+            fi
+            AC_DEFINE(_CRT_SECURE_NO_DEPRECATE)
+            AC_DEFINE(_CRT_NONSTDC_NO_DEPRECATE)
+        elif test "$_CC_MAJOR_VERSION" = "15"; then
+            _CC_SUITE=9
+            CXXFLAGS="$CXXFLAGS -Zc:wchar_t-"
+            LDFLAGS="$LDFLAGS -MANIFESTUAC:NO"
+            _USE_DYNAMICBASE=1
+            AC_DEFINE(_CRT_SECURE_NO_WARNINGS)
+            AC_DEFINE(_CRT_NONSTDC_NO_WARNINGS)
+        else
+            AC_MSG_ERROR([This version of the MSVC compiler, $CC_VERSION , is unsupported.])
+        fi
+
+        _MOZ_RTTI_FLAGS_ON='-GR'
+        _MOZ_RTTI_FLAGS_OFF='-GR-'
+        _MOZ_EXCEPTIONS_FLAGS_ON='-EHsc'
+        _MOZ_EXCEPTIONS_FLAGS_OFF=''
+
+        if test -n "$WIN32_REDIST_DIR"; then
+            WIN32_REDIST_DIR=`cd "$WIN32_REDIST_DIR" && pwd`
+        fi
+	
+        # bug #249782
+        # ensure that mt.exe is Microsoft (R) Manifest Tool and not magnetic tape manipulation utility (or something else)
+        if test "$_CC_SUITE" -ge "8"; then
+                changequote(,)
+                _MSMT_VER_FILTER='s|.* \([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*|\1|p'
+                changequote([,])
+
+                MSMT_TOOL=`mt 2>&1|grep 'Microsoft (R) Manifest Tool'`
+                if test -n "$MSMT_TOOL"; then
+                        MSMANIFEST_TOOL_VERSION=`echo ${MSMT_TOOL}|sed -ne "$_MSMT_VER_FILTER"`
+                        if test -z "$MSMANIFEST_TOOL_VERSION"; then
+                                AC_MSG_WARN([Unknown version of the Microsoft (R) Manifest Tool.])
+                        fi
+                        MSMANIFEST_TOOL=1
+                        unset MSMT_TOOL
+                else
+                        AC_MSG_ERROR([Microsoft (R) Manifest Tool must be in your \$PATH.])
+                fi
+        fi
+
+        # Check linker version
+        _LD_FULL_VERSION=`"${LD}" -v 2>&1 | sed -nre "$_MSVC_VER_FILTER"`
+        _LD_MAJOR_VERSION=`echo ${_LD_FULL_VERSION} | $AWK -F\. '{ print $1 }'`
+        if test "$_LD_MAJOR_VERSION" != "$_CC_SUITE"; then
+            AC_MSG_ERROR([The linker major version, $_LD_FULL_VERSION,  does not match the compiler suite version, $_CC_SUITE.])
+        fi
+        INCREMENTAL_LINKER=1
+
+        # Check midl version
+        _MIDL_FULL_VERSION=`"${MIDL}" -v 2>&1 | sed -nre "$_MSVC_VER_FILTER"`
+        _MIDL_MAJOR_VERSION=`echo ${_MIDL_FULL_VERSION} | $AWK -F\. '{ print $1 }'`
+        _MIDL_MINOR_VERSION=`echo ${_MIDL_FULL_VERSION} | $AWK -F\. '{ print $2 }'`
+        _MIDL_REV_VERSION=`echo ${_MIDL_FULL_VERSION} | $AWK -F\. '{ print $3 }'`
+         # Add flags if necessary
+         AC_MSG_CHECKING([for midl flags])
+         if test \( "$_MIDL_MAJOR_VERSION" -gt "6" \) -o \( "$_MIDL_MAJOR_VERSION" = "6" -a "$_MIDL_MINOR_VERSION" -gt "0" \) -o \( "$_MIDL_MAJOR_VERSION" = "6" -a "$_MIDL_MINOR_VERSION" = "00" -a "$_MIDL_REV_VERSION" -gt "359" \); then
+             # Starting with MIDL version 6.0.359, the MIDL compiler
+             # generates /Oicf /robust stubs by default, which is not
+             # compatible with versions of Windows older than Win2k.
+             # This switches us back to the old behaviour. When we drop
+             # support for Windows older than Win2k, we should remove
+             # this.
+             MIDL_FLAGS="${MIDL_FLAGS} -no_robust"
+             AC_MSG_RESULT([need -no_robust])
+         else
+             MIDL_FLAGS="${MIDL_FLAGS}"
+             AC_MSG_RESULT([none needed])
+        fi
+        
+        unset _MSVC_VER_FILTER
+        
+    else
+        # Check w32api version
+        _W32API_MAJOR_VERSION=`echo $W32API_VERSION | $AWK -F\. '{ print $1 }'`
+        _W32API_MINOR_VERSION=`echo $W32API_VERSION | $AWK -F\. '{ print $2 }'`
+        AC_MSG_CHECKING([for w32api version >= $W32API_VERSION])
+        AC_TRY_COMPILE([#include <w32api.h>],
+            #if (__W32API_MAJOR_VERSION < $_W32API_MAJOR_VERSION) || \
+                (__W32API_MAJOR_VERSION == $_W32API_MAJOR_VERSION && \
+                 __W32API_MINOR_VERSION < $_W32API_MINOR_VERSION)
+                #error "test failed."
+            #endif
+            , [ res=yes ], [ res=no ])
+        AC_MSG_RESULT([$res])
+        if test "$res" != "yes"; then
+            AC_MSG_ERROR([w32api version $W32API_VERSION or higher required.])
+        fi
+        # Check windres version
+        AC_MSG_CHECKING([for windres version >= $WINDRES_VERSION])
+        _WINDRES_VERSION=`${WINDRES} --version 2>&1 | grep -i windres 2>/dev/null | $AWK '{ print $3 }'`
+        AC_MSG_RESULT([$_WINDRES_VERSION])
+        _WINDRES_MAJOR_VERSION=`echo $_WINDRES_VERSION | $AWK -F\. '{ print $1 }'`
+        _WINDRES_MINOR_VERSION=`echo $_WINDRES_VERSION | $AWK -F\. '{ print $2 }'`
+        _WINDRES_RELEASE_VERSION=`echo $_WINDRES_VERSION | $AWK -F\. '{ print $3 }'`
+        WINDRES_MAJOR_VERSION=`echo $WINDRES_VERSION | $AWK -F\. '{ print $1 }'`
+        WINDRES_MINOR_VERSION=`echo $WINDRES_VERSION | $AWK -F\. '{ print $2 }'`
+        WINDRES_RELEASE_VERSION=`echo $WINDRES_VERSION | $AWK -F\. '{ print $3 }'`
+        if test "$_WINDRES_MAJOR_VERSION" -lt "$WINDRES_MAJOR_VERSION" -o \
+                "$_WINDRES_MAJOR_VERSION" -eq "$WINDRES_MAJOR_VERSION" -a \
+                "$_WINDRES_MINOR_VERSION" -lt "$WINDRES_MINOR_VERSION" -o \
+                "$_WINDRES_MAJOR_VERSION" -eq "$WINDRES_MAJOR_VERSION" -a \
+                "$_WINDRES_MINOR_VERSION" -eq "$WINDRES_MINOR_VERSION" -a \
+                "$_WINDRES_RELEASE_VERSION" -lt "$WINDRES_RELEASE_VERSION"
+        then
+            AC_MSG_ERROR([windres version $WINDRES_VERSION or higher is required to build.])
+        fi
+    fi # !GNU_CC
+
+    AC_DEFINE_UNQUOTED(WINVER,0x$WINVER)
+    AC_DEFINE_UNQUOTED(_WIN32_WINNT,0x$WINVER)
+    # Require OS features provided by IE 5.0
+    AC_DEFINE_UNQUOTED(_WIN32_IE,0x0500)
+    ;;
+esac
+
+dnl Test breaks icc on OS/2 && MSVC
+if test "$CC" != "icc" -a -z "$_WIN32_MSVC"; then
+    AC_PROG_CC_C_O
+    if grep "NO_MINUS_C_MINUS_O 1" ./confdefs.h >/dev/null; then
+        USING_HCC=1
+        _OLDCC=$CC
+        _OLDCXX=$CXX
+        CC="${srcdir}/build/hcc '$CC'"
+        CXX="${srcdir}/build/hcpp '$CXX'"
+    fi
+fi
+
+AC_PROG_CPP
+AC_PROG_CXXCPP
+
+if test -n "$_WIN32_MSVC"; then
+    SKIP_PATH_CHECKS=1
+    SKIP_COMPILER_CHECKS=1
+    SKIP_LIBRARY_CHECKS=1
+fi
+
+fi # COMPILE_ENVIRONMENT
+
+AC_SUBST(MIDL_FLAGS)
+AC_SUBST(_MSC_VER)
+
+AC_SUBST(GNU_AS)
+AC_SUBST(GNU_LD)
+AC_SUBST(GNU_CC)
+AC_SUBST(GNU_CXX)
+AC_SUBST(INTEL_CC)
+AC_SUBST(INTEL_CXX)
+
+dnl ========================================================
+dnl Checks for programs.
+dnl ========================================================
+AC_PROG_INSTALL
+AC_PROG_LN_S
+AC_PATH_PROGS(PERL, $PERL perl5 perl )
+if test -z "$PERL" || test "$PERL" = ":"; then
+    AC_MSG_ERROR([perl not found in \$PATH])
+fi
+
+if test -z "$TINDERBOX_SKIP_PERL_VERSION_CHECK"; then
+AC_MSG_CHECKING([for minimum required perl version >= $PERL_VERSION])
+_perl_version=`PERL_VERSION=$PERL_VERSION $PERL -e 'print "$]"; if ($] >= $ENV{PERL_VERSION}) { exit(0); } else { exit(1); }' 2>&5`
+_perl_res=$?
+AC_MSG_RESULT([$_perl_version])
+
+if test "$_perl_res" != 0; then
+    AC_MSG_ERROR([Perl $PERL_VERSION or higher is required.])
+fi
+fi
+
+AC_MSG_CHECKING([for full perl installation])
+_perl_archlib=`$PERL -e 'use Config; if ( -d $Config{archlib} ) { exit(0); } else { exit(1); }' 2>&5`
+_perl_res=$?
+if test "$_perl_res" != 0; then
+    AC_MSG_RESULT([no])
+    AC_MSG_ERROR([Cannot find Config.pm or \$Config{archlib}.  A full perl installation is required.])
+else
+    AC_MSG_RESULT([yes])    
+fi
+
+AC_PATH_PROGS(PYTHON, $PYTHON python)
+if test -z "$PYTHON"; then
+    AC_MSG_ERROR([python was not found in \$PATH])
+fi
+echo PYTHON="$PYTHON"
+
+AC_PATH_PROGS(NSINSTALL_BIN, nsinstall )
+if test -z "$COMPILE_ENVIRONMENT"; then
+if test -z "$NSINSTALL_BIN" || test "$NSINSTALL_BIN" = ":"; then
+    NSINSTALL_BIN='$(PYTHON) $(MOZILLA_SRCDIR)/config/nsinstall.py'
+fi
+fi
+AC_SUBST(NSINSTALL_BIN)
+
+AC_PATH_PROG(DOXYGEN, doxygen, :)
+AC_PATH_PROG(WHOAMI, whoami, :)
+AC_PATH_PROG(AUTOCONF, autoconf, :)
+AC_PATH_PROG(UNZIP, unzip, :)
+AC_PATH_PROGS(ZIP, zip)
+if test -z "$ZIP" || test "$ZIP" = ":"; then
+    AC_MSG_ERROR([zip not found in \$PATH])
+fi
+AC_PATH_PROG(SYSTEM_MAKEDEPEND, makedepend)
+AC_PATH_PROG(XARGS, xargs)
+if test -z "$XARGS" || test "$XARGS" = ":"; then
+    AC_MSG_ERROR([xargs not found in \$PATH .])
+fi
+
+if test "$COMPILE_ENVIRONMENT"; then
+
+dnl ========================================================
+dnl = Mac OS X toolchain support
+dnl ========================================================
+
+case "$target_os" in
+darwin*)
+    dnl Current known valid versions for GCC_VERSION are 2.95.2 3.1 3.3 4.0.
+    dnl 4.0 identifies itself as 4.0.x, so strip the decidecimal for
+    dnl the environment and includedir purposes (when using an SDK, below),
+    dnl but remember the full version number for the libdir (SDK).
+    changequote(,)
+    GCC_VERSION_FULL=`echo $CXX_VERSION | $PERL -pe 's/^.*gcc version ([^ ]*).*/$1/'`
+    GCC_VERSION=`echo $GCC_VERSION_FULL | $PERL -pe '(split(/\./))[0]>=4&&s/(^\d*\.\d*).*/$1/;'`
+    changequote([,])
+    if test "$GCC_VERSION_FULL" = "4.0.0" ; then
+        dnl Bug 280479, but this keeps popping up in bug 292530 too because
+        dnl 4.0.0/4061 is the default compiler in Tiger.
+        changequote(,)
+        GCC_BUILD=`echo $CXX_VERSION | $PERL -pe 's/^.*build ([^ )]*).*/$1/'`
+        changequote([,])
+        if test "$GCC_BUILD" = "4061" ; then
+            AC_MSG_ERROR([You are attempting to use Apple gcc 4.0 build 4061.
+This compiler was supplied with Xcode 2.0, and contains bugs that prevent it
+from building Mozilla. Upgrade to Xcode 2.1 or later.])
+        fi
+    fi
+
+    dnl xcodebuild needs GCC_VERSION defined in the environment, since it
+    dnl doesn't respect the CC/CXX setting.  With GCC_VERSION set, it will use
+    dnl /usr/bin/g(cc|++)-$GCC_VERSION.
+    AC_PATH_PROGS(PBBUILD, pbbuild xcodebuild pbxbuild)
+
+    case "$PBBUILD" in
+      *xcodebuild*)
+        changequote(,)
+        XCODEBUILD_VERSION=`$PBBUILD -version 2>/dev/null | xargs | sed -e 's/.*DevToolsCore-\([0-9]*\).*/\1/'`
+        changequote([,])
+        if test -n "$XCODEBUILD_VERSION" && test "$XCODEBUILD_VERSION" -ge 620 ; then
+          HAS_XCODE_2_1=1;
+        fi
+      ;;
+    esac
+
+    dnl sdp was formerly in /Developer/Tools.  As of Mac OS X 10.4 (Darwin 8),
+    dnl it has moved into /usr/bin.
+    AC_PATH_PROG(SDP, sdp, :, [$PATH:/usr/bin:/Developer/Tools])
+    ;;
+esac
+
+AC_SUBST(GCC_VERSION)
+AC_SUBST(XCODEBUILD_VERSION)
+AC_SUBST(HAS_XCODE_2_1)
+
+dnl The universal machinery sets UNIVERSAL_BINARY to inform packager.mk
+dnl that a universal binary is being produced.
+AC_SUBST(UNIVERSAL_BINARY)
+
+dnl ========================================================
+dnl Check for MacOS deployment target version
+dnl ========================================================
+
+MOZ_ARG_ENABLE_STRING(macos-target,
+                      [  --enable-macos-target=VER (default=10.4)
+                          Set the minimum MacOS version needed at runtime],
+                      [_MACOSX_DEPLOYMENT_TARGET=$enableval])
+
+case "$target" in
+*-darwin*)
+    if test -n "$_MACOSX_DEPLOYMENT_TARGET" ; then
+        dnl Use the specified value
+        export MACOSX_DEPLOYMENT_TARGET=$_MACOSX_DEPLOYMENT_TARGET
+        AC_DEFINE_UNQUOTED(__ENVIRONMENT_MAC_OS_X_VERION_MIN_REQUIRED__,$_MACOSX_DEPLOYMENT_TARGET)
+    elif test -z "$MACOSX_DEPLOYMENT_TARGET" ; then
+        dnl No value specified on the command line or in the environment,
+        dnl use the lesser of the application's minimum or the architecture's
+        dnl minimum.
+        export MACOSX_DEPLOYMENT_TARGET=10.4
+    fi
+    ;;
+esac
+
+AC_SUBST(MACOSX_DEPLOYMENT_TARGET)
+
+dnl ========================================================
+dnl = Mac OS X SDK support
+dnl ========================================================
+MACOS_SDK_DIR=
+NEXT_ROOT=
+MOZ_ARG_WITH_STRING(macos-sdk,
+[  --with-macos-sdk=dir   Location of platform SDK to use (Mac OS X only)],
+    MACOS_SDK_DIR=$withval)
+
+dnl MACOS_SDK_DIR will be set to the SDK location whenever one is in use.
+dnl NEXT_ROOT will be set and exported only if it's needed.
+AC_SUBST(MACOS_SDK_DIR)
+AC_SUBST(NEXT_ROOT)
+
+if test "$MACOS_SDK_DIR"; then
+  dnl Sync this section with the ones in NSPR and NSS.
+  dnl Changes to the cross environment here need to be accounted for in
+  dnl the libIDL checks (below) and xpidl build.
+
+  if test ! -d "$MACOS_SDK_DIR"; then
+    AC_MSG_ERROR([SDK not found.  When using --with-macos-sdk, you must
+specify a valid SDK.  SDKs are installed when the optional cross-development
+tools are selected during the Xcode/Developer Tools installation.])
+  fi
+
+  GCC_VERSION_MAJOR=`echo $GCC_VERSION_FULL | $PERL -pe 's/(^\d*).*/$1/;'`
+  if test "$GCC_VERSION_MAJOR" -lt "4" ; then
+    SDK_C_INCLUDE="-isystem ${MACOS_SDK_DIR}/usr/include/gcc/darwin/${GCC_VERSION} -isystem ${MACOS_SDK_DIR}/usr/include -F${MACOS_SDK_DIR}/System/Library/Frameworks"
+    if test -d "${MACOS_SDK_DIR}/Library/Frameworks" ; then
+      SDK_C_INCLUDE="$SDK_C_INCLUDE -F${MACOS_SDK_DIR}/Library/Frameworks"
+    fi
+    SDK_CXX_INCLUDE="-I${MACOS_SDK_DIR}/usr/include/gcc/darwin/${GCC_VERSION}/c++ -I${MACOS_SDK_DIR}/usr/include/gcc/darwin/${GCC_VERSION}/c++/ppc-darwin -I${MACOS_SDK_DIR}/usr/include/gcc/darwin/${GCC_VERSION}/c++/backward"
+
+    CFLAGS="$CFLAGS -nostdinc ${SDK_C_INCLUDE}"
+    CXXFLAGS="$CXXFLAGS -nostdinc -nostdinc++ ${SDK_CXX_INCLUDE} ${SDK_C_INCLUDE}"
+
+    dnl CPP/CXXCPP needs to be set for AC_CHECK_HEADER.
+    CPP="$CPP -nostdinc ${SDK_C_INCLUDE}"
+    CXXCPP="$CXXCPP -nostdinc -nostdinc++ ${SDK_CXX_INCLUDE} ${SDK_C_INCLUDE}"
+
+    dnl ld support for -syslibroot is compiler-agnostic, but only available
+    dnl on Tiger.  Although it's possible to switch on the build host's
+    dnl OS release to use ld -syslibroot when available, ld -syslibroot will
+    dnl cause warnings as long as NEXT_ROOT is set.  NEXT_ROOT should be
+    dnl set because both the compiler and linker use it.
+    LIBS="-L${MACOS_SDK_DIR}/usr/lib/gcc/darwin -L${MACOS_SDK_DIR}/usr/lib/gcc/darwin/${GCC_VERSION_FULL} -L${MACOS_SDK_DIR}/usr/lib $LIBS"
+    export NEXT_ROOT=$MACOS_SDK_DIR
+
+    if test -n "$CROSS_COMPILE" ; then
+      dnl NEXT_ROOT will be in the environment, but it shouldn't be set for
+      dnl the build host.  HOST_CXX is presently unused.
+      HOST_CC="NEXT_ROOT= $HOST_CC"
+      HOST_CXX="NEXT_ROOT= $HOST_CXX"
+    fi
+  else
+    dnl gcc >= 4.0 uses different paths than above, but knows how to find
+    dnl them itself.
+    CFLAGS="$CFLAGS -isysroot ${MACOS_SDK_DIR}"
+    CXXFLAGS="$CXXFLAGS -isysroot ${MACOS_SDK_DIR}"
+
+    dnl CPP/CXXCPP needs to be set for AC_CHECK_HEADER.
+    CPP="$CPP -isysroot ${MACOS_SDK_DIR}"
+    CXXCPP="$CXXCPP -isysroot ${MACOS_SDK_DIR}"
+
+    if test "$GCC_VERSION_FULL" = "4.0.0" ; then
+      dnl If gcc >= 4.0, we're guaranteed to be on Tiger, which has an ld
+      dnl that supports -syslibroot.  Don't set NEXT_ROOT because it will
+      dnl be ignored and cause warnings when -syslibroot is specified.
+      dnl gcc 4.0.1 will pass -syslibroot to ld automatically based on
+      dnl the -isysroot it receives, so this is only needed with 4.0.0.
+      LDFLAGS="$LDFLAGS -Wl,-syslibroot,${MACOS_SDK_DIR}"
+    fi
+  fi
+
+  AC_LANG_SAVE
+  AC_MSG_CHECKING([for valid compiler/Mac OS X SDK combination])
+  AC_LANG_CPLUSPLUS
+  AC_TRY_COMPILE([#include <new>
+                 int main() { return 0; }],
+   result=yes,
+   result=no)
+  AC_LANG_RESTORE
+  AC_MSG_RESULT($result)
+
+  if test "$result" = "no" ; then
+    AC_MSG_ERROR([The selected compiler and Mac OS X SDK are incompatible.])
+  fi
+fi
+
+fi # COMPILE_ENVIRONMENT
+
+dnl Be sure the make we use is GNU make.
+dnl on win32, gmake.exe is the generally the wrong version
+case "$host_os" in
+cygwin*|mingw*|mks*|msvc*)
+    AC_PATH_PROGS(MAKE, $MAKE make gmake, :)
+    ;;
+*)
+    AC_PATH_PROGS(MAKE, $MAKE gmake make, :)
+    ;;
+esac
+_make_try=`$MAKE --version 2>/dev/null | grep GNU`
+if test ! "$_make_try"
+then
+	echo
+	echo "*** $MAKE is not GNU Make.  You will not be able to build Mozilla without GNU Make."
+	echo
+	exit 1
+fi
+dnl Now exit if version if < MAKE_VERSION
+rm -f dummy.mk
+echo 'all: ; @echo $(MAKE_VERSION)' > dummy.mk
+_make_vers=`$MAKE --no-print-directory -f dummy.mk all 2>/dev/null`
+rm -f dummy.mk
+_MAKE_MAJOR_VERSION=`echo $_make_vers | $AWK -F\. '{ print $1 }'`
+_MAKE_MINOR_VERSION=`echo $_make_vers | $AWK -F\. '{ print $2 }'`
+MAKE_MAJOR_VERSION=`echo $MAKE_VERSION | $AWK -F\. '{ print $1 }'`
+MAKE_MINOR_VERSION=`echo $MAKE_VERSION | $AWK -F\. '{ print $2 }'`
+if test "$_MAKE_MAJOR_VERSION" -lt "$MAKE_MAJOR_VERSION" || \
+   test "$_MAKE_MAJOR_VERSION" = "$MAKE_MAJOR_VERSION" -a \
+        "$_MAKE_MINOR_VERSION" -lt "$MAKE_MINOR_VERSION"; then
+   AC_MSG_ERROR([GNU Make $MAKE_VERSION or higher is required to build Mozilla.])
+fi
+AC_SUBST(MAKE)
+
+if test "$COMPILE_ENVIRONMENT"; then
+
+AC_PATH_XTRA
+
+dnl Check in X11 include directory too.
+if test "$no_x" != "yes"; then
+    CPPFLAGS="$CPPFLAGS $X_CFLAGS"
+fi
+
+XCFLAGS="$X_CFLAGS"
+
+fi # COMPILE_ENVIRONMENT
+
+dnl ========================================================
+dnl set the defaults first
+dnl ========================================================
+AS_BIN=$AS
+AR_FLAGS='cr $@'
+AR_LIST='$(AR) t'
+AR_EXTRACT='$(AR) x'
+AR_DELETE='$(AR) d'
+AS='$(CC)'
+AS_DASH_C_FLAG='-c'
+DLL_PREFIX=lib
+LIB_PREFIX=lib
+DLL_SUFFIX=.so
+OBJ_SUFFIX=o
+LIB_SUFFIX=a
+ASM_SUFFIX=s
+IMPORT_LIB_SUFFIX=
+TARGET_MD_ARCH=unix
+DIRENT_INO=d_ino
+CYGWIN_WRAPPER=
+WIN_TOP_SRC=
+MOZ_USER_DIR=".mozilla"
+HOST_AR='$(AR)'
+HOST_AR_FLAGS='$(AR_FLAGS)'
+
+MOZ_JPEG_CFLAGS=
+MOZ_JPEG_LIBS='$(call EXPAND_LIBNAME_PATH,mozjpeg,$(DEPTH)/mozilla/jpeg)'
+MOZ_ZLIB_CFLAGS=
+MOZ_ZLIB_LIBS='$(call EXPAND_LIBNAME_PATH,mozz,$(DEPTH)/mozilla/modules/zlib/src)'
+MOZ_BZ2_CFLAGS=
+MOZ_BZ2_LIBS='$(call EXPAND_LIBNAME_PATH,bz2,$(DEPTH)/mozilla/modules/libbz2/src)'
+MOZ_PNG_CFLAGS=
+MOZ_PNG_LIBS='$(call EXPAND_LIBNAME_PATH,mozpng,$(DEPTH)/mozilla/modules/libimg/png)'
+
+MOZ_JS_LIBS='-L$(LIBXUL_DIST)/bin -lmozjs'
+DYNAMIC_XPCOM_LIBS='-L$(LIBXUL_DIST)/bin -lxpcom -lxpcom_core'
+MOZ_FIX_LINK_PATHS='-Wl,-rpath-link,$(LIBXUL_DIST)/bin'
+XPCOM_FROZEN_LDOPTS='-L$(LIBXUL_DIST)/bin -lxpcom'
+LIBXUL_LIBS='$(XPCOM_FROZEN_LDOPTS) -lxul'
+XPCOM_GLUE_LDOPTS='$(LIBXUL_DIST)/lib/$(LIB_PREFIX)xpcomglue_s.$(LIB_SUFFIX) $(XPCOM_FROZEN_LDOPTS)'
+XPCOM_STANDALONE_GLUE_LDOPTS='$(LIBXUL_DIST)/lib/$(LIB_PREFIX)xpcomglue.$(LIB_SUFFIX)'
+
+MOZ_COMPONENT_NSPR_LIBS='-L$(LIBXUL_DIST)/bin $(NSPR_LIBS)'
+MOZ_XPCOM_OBSOLETE_LIBS='-L$(LIBXUL_DIST)/lib -lxpcom_compat'
+
+USE_DEPENDENT_LIBS=1
+
+_PLATFORM_DEFAULT_TOOLKIT=cairo-gtk2
+MOZ_GFX_TOOLKIT='$(MOZ_WIDGET_TOOLKIT)'
+
+MOZ_ENABLE_POSTSCRIPT=1 
+
+if test -n "$CROSS_COMPILE"; then
+    OS_TARGET="${target_os}"
+    OS_ARCH=`echo $target_os | sed -e 's|/|_|g'`
+    OS_RELEASE=
+    case "${target_os}" in
+        linux*)       OS_ARCH=Linux OS_TARGET=Linux ;;
+        kfreebsd*-gnu) OS_ARCH=GNU_kFreeBSD OS_TARGET=GNU_kFreeBSD ;;
+        solaris*)     OS_ARCH=SunOS OS_RELEASE=5 ;;
+        mingw*)       OS_ARCH=WINNT ;;
+        wince*)       OS_ARCH=WINCE ;;
+        darwin*)      OS_ARCH=Darwin OS_TARGET=Darwin ;;
+    esac
+else
+    OS_TARGET=`uname -s`
+    OS_ARCH=`uname -s | sed -e 's|/|_|g'`
+    OS_RELEASE=`uname -r`
+fi
+
+# Before this used `uname -m` when not cross compiling
+# but that breaks when you have a 64 bit kernel with a 32 bit userland.
+OS_TEST="${target_cpu}"
+
+_COMPILER_PREFIX=
+
+HOST_OS_ARCH=`echo $host_os | sed -e 's|/|_|g'`
+
+#######################################################################
+# Master "Core Components" macros for getting the OS target           #
+#######################################################################
+
+#
+# Note: OS_TARGET should be specified on the command line for gmake.
+# When OS_TARGET=WIN95 is specified, then a Windows 95 target is built.
+# The difference between the Win95 target and the WinNT target is that
+# the WinNT target uses Windows NT specific features not available
+# in Windows 95. The Win95 target will run on Windows NT, but (supposedly)
+# at lesser performance (the Win95 target uses threads; the WinNT target
+# uses fibers).
+#
+# When OS_TARGET=WIN16 is specified, then a Windows 3.11 (16bit) target
+# is built. See: win16_3.11.mk for lots more about the Win16 target.
+#
+# If OS_TARGET is not specified, it defaults to $(OS_ARCH), i.e., no
+# cross-compilation.
+#
+
+#
+# The following hack allows one to build on a WIN95 machine (as if
+# s/he were cross-compiling on a WINNT host for a WIN95 target).
+# It also accomodates for MKS's uname.exe.  If you never intend
+# to do development on a WIN95 machine, you don't need this hack.
+#
+case "$OS_ARCH" in
+WIN95)
+    OS_ARCH=WINNT
+    OS_TARGET=WIN95
+    ;;
+Windows_95)
+    OS_ARCH=Windows_NT
+    OS_TARGET=WIN95
+    ;;
+Windows_98)
+    OS_ARCH=Windows_NT
+    OS_TARGET=WIN95
+    ;;
+CYGWIN_9*|CYGWIN_ME*)
+    OS_ARCH='CYGWIN_NT-4.0'
+    OS_TARGET=WIN95
+    ;;
+esac
+
+#
+# Define and override various archtecture-specific variables, including
+# HOST_OS_ARCH
+# OS_ARCH
+# OS_TEST
+# OS_TARGET
+# OS_RELEASE
+# OS_MINOR_RELEASE
+#
+
+case "$HOST_OS_ARCH" in
+cygwin*|mingw*|mks*|msvc*)
+    HOST_OS_ARCH=WINNT
+    ;;
+linux*)
+    HOST_OS_ARCH=Linux
+    ;;
+solaris*)
+    HOST_OS_ARCH=SunOS
+    ;;
+BSD_386)
+    HOST_OS_ARCH=BSD
+    ;;
+dgux)
+    HOST_OS_ARCH=DGUX
+    ;;
+IRIX64)
+    HOST_OS_ARCH=IRIX
+    ;;
+UNIX_SV)
+    if "`cat /etc/bcheckrc | grep -c NCR 2>/dev/null`" != "0"; then
+        HOST_OS_ARCH=NCR
+    else
+        HOST_OS_ARCH=UNIXWARE
+    fi
+    ;;
+ncr)
+    HOST_OS_ARCH=NCR
+    ;;
+UNIX_SYSTEM_V)
+    HOST_OS_ARCH=NEC
+    ;;
+OSF1)
+    ;;
+*OpenVMS*)
+    HOST_OS_ARCH=OpenVMS
+    ;;
+OS_2)
+    HOST_OS_ARCH=OS2
+    ;;
+QNX)
+    ;;
+SCO_SV)
+    HOST_OS_ARCH=SCOOS
+    ;;
+SINIX-N | SINIX-Y | SINIX-Z |ReliantUNIX-M)
+    HOST_OS_ARCH=SINIX
+    ;;
+UnixWare)
+    HOST_OS_ARCH=UNIXWARE
+    ;;
+esac
+
+case "$OS_ARCH" in
+WINNT)
+    OS_TEST=`uname -p`
+    ;;
+Windows_NT)
+#
+# If uname -s returns "Windows_NT", we assume that we are using
+# the uname.exe in MKS toolkit.
+#
+# The -r option of MKS uname only returns the major version number.
+# So we need to use its -v option to get the minor version number.
+# Moreover, it doesn't have the -p option, so we need to use uname -m.
+#
+    OS_ARCH=WINNT
+    OS_TARGET=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}"
+    ;;
+CYGWIN32_NT|CYGWIN_NT*|MINGW*_NT*)
+#
+# If uname -s returns "CYGWIN_NT-4.0", we assume that we are using
+# the uname.exe in the Cygwin tools.
+# Prior to the Beta 20 release, Cygwin was called GNU-Win32.
+# If uname -s returns "CYGWIN32/NT", we assume that we are using
+# the uname.exe in the GNU-Win32 tools.
+# If uname -s returns MINGW32_NT-5.1, we assume that we are using
+# the uname.exe in the MSYS tools.
+#
+    OS_RELEASE=`expr $OS_ARCH : '.*NT-\(.*\)'`
+    OS_ARCH=WINNT
+    OS_TARGET=WINNT
+    ;;
+AIX)
+    OS_RELEASE=`uname -v`.`uname -r`
+    OS_TEST=`uname -p`
+    ;;
+BSD_386)
+    OS_ARCH=BSD
+    ;;
+dgux)
+    OS_ARCH=DGUX
+    ;;
+IRIX64)
+    OS_ARCH=IRIX
+    ;;
+UNIX_SV)
+    if "`cat /etc/bcheckrc | grep -c NCR 2>/dev/null`" != "0"; then
+        OS_ARCH=NCR
+    else
+        OS_ARCH=UNIXWARE
+        OS_RELEASE=`uname -v`
+    fi
+    ;;
+ncr)
+    OS_ARCH=NCR
+    ;;
+UNIX_SYSTEM_V)
+    OS_ARCH=NEC
+    ;;
+OSF1)
+    case `uname -v` in
+    148)
+        OS_RELEASE=V3.2C
+        ;;
+    564)
+        OS_RELEASE=V4.0B
+        ;;
+    878)
+        OS_RELEASE=V4.0D
+        ;;
+    esac
+    ;;
+*OpenVMS*)
+    OS_ARCH=OpenVMS
+    OS_RELEASE=`uname -v`
+    OS_TEST=`uname -p`
+    ;;
+OS_2)
+    OS_ARCH=OS2
+    OS_TARGET=OS2
+    OS_RELEASE=`uname -v`
+    ;;
+QNX)
+    if test "$OS_TARGET" != "NTO"; then
+        changequote(,)
+        OS_RELEASE=`uname -v | sed 's/^\([0-9]\)\([0-9]*\)$/\1.\2/'`
+        changequote([,])
+    fi
+    OS_TEST=x86
+    ;;
+SCO_SV)
+    OS_ARCH=SCOOS
+    OS_RELEASE=5.0
+    ;;
+SINIX-N | SINIX-Y | SINIX-Z |ReliantUNIX-M)
+    OS_ARCH=SINIX
+    OS_TEST=`uname -p`
+    ;;
+UnixWare)
+    OS_ARCH=UNIXWARE
+    OS_RELEASE=`uname -v`
+    ;;
+WINCE)
+    OS_ARCH=WINCE
+    OS_TARGET=WINCE
+    ;;
+Darwin)
+    case "${target_cpu}" in
+    powerpc*)
+        OS_TEST=ppc
+        ;;
+    i*86*)
+        OS_TEST=i386 
+        ;;
+    *)
+        if test -z "$CROSS_COMPILE" ; then
+            OS_TEST=`uname -p`
+        fi
+        ;;
+    esac
+    ;;
+esac
+
+if test "$OS_ARCH" = "NCR"; then
+    changequote(,)
+    OS_RELEASE=`awk '{print $3}' /etc/.relid | sed 's/^\([0-9]\)\(.\)\(..\)\(.*\)$/\2.\3/'`
+    changequote([,])
+fi
+
+# Only set CPU_ARCH if we recognize the value of OS_TEST
+
+case "$OS_TEST" in
+*86 | i86pc)
+    CPU_ARCH=x86
+    ;;
+
+powerpc* | ppc)
+    CPU_ARCH=ppc
+    ;;
+
+Alpha | alpha | ALPHA)
+    CPU_ARCH=Alpha
+    ;;
+
+hppa* | parisc)
+    CPU_ARCH=hppa
+    ;;
+
+sun4u | sparc*)
+    CPU_ARCH=sparc
+    ;;
+
+x86_64 | ia64)
+    CPU_ARCH="$OS_TEST"
+    ;;
+esac
+
+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
+OS_CONFIG="${OS_TARGET}${OS_RELEASE}"
+
+dnl ========================================================
+dnl GNU specific defaults
+dnl ========================================================
+if test "$GNU_CC"; then
+    # FIXME: Let us build with strict aliasing. bug 414641.
+    CFLAGS="$CFLAGS -fno-strict-aliasing"
+    MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-h,$@ -o $@'
+    MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-h,$@ -o $@'
+    DSO_LDOPTS='-shared'
+    if test "$GCC_USE_GNU_LD"; then
+        # Don't allow undefined symbols in libraries
+        DSO_LDOPTS="$DSO_LDOPTS -Wl,-z,defs"
+    fi
+    WARNINGS_AS_ERRORS='-Werror'
+    DSO_CFLAGS=''
+    DSO_PIC_CFLAGS='-fPIC'
+    _MOZ_RTTI_FLAGS_ON=${_COMPILER_PREFIX}-frtti
+    _MOZ_RTTI_FLAGS_OFF=${_COMPILER_PREFIX}-fno-rtti
+    _MOZ_EXCEPTIONS_FLAGS_ON='-fhandle-exceptions'
+    _MOZ_EXCEPTIONS_FLAGS_OFF='-fno-handle-exceptions'
+
+    # Turn on GNU specific features
+    # -Wall - turn on all warnings
+    # -pedantic - make compiler warn about non-ANSI stuff, and
+    #             be a little bit stricter
+    # Warnings slamm took out for now (these were giving more noise than help):
+    # -Wbad-function-cast - warns when casting a function to a new return type
+    # -Wconversion - complained when char's or short's were used a function args
+    # -Wshadow - removed because it generates more noise than help --pete
+    _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wall -W -Wno-unused -Wpointer-arith"
+    if test -z "$INTEL_CC"; then
+       # Don't use -Wcast-align with ICC
+       case "$CPU_ARCH" in
+           # And don't use it on hppa, ia64, sparc, since it's noisy there
+           hppa | ia64 | sparc)
+           ;;
+           *)
+        _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wcast-align"
+           ;;
+       esac
+    fi
+
+    dnl Turn pedantic on but disable the warnings for long long
+    _PEDANTIC=1
+
+    if test -z "$INTEL_CC"; then
+      _IGNORE_LONG_LONG_WARNINGS=1
+      _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -W"
+    else
+      _IGNORE_LONG_LONG_WARNINGS=
+    fi
+
+
+    _DEFINES_CFLAGS='-include $(DEPTH)/mozilla-config.h -DMOZILLA_CLIENT'
+    _USE_CPP_INCLUDE_FLAG=1
+else
+    MKSHLIB='$(LD) $(DSO_LDOPTS) -h $@ -o $@'
+    MKCSHLIB='$(LD) $(DSO_LDOPTS) -h $@ -o $@'
+
+    DSO_LDOPTS='-shared'
+    if test "$GNU_LD"; then
+        # Don't allow undefined symbols in libraries
+        DSO_LDOPTS="$DSO_LDOPTS -z defs"
+    fi
+
+    DSO_CFLAGS=''
+    DSO_PIC_CFLAGS='-KPIC'
+    _DEFINES_CFLAGS='$(ACDEFINES) -D_MOZILLA_CONFIG_H_ -DMOZILLA_CLIENT'
+fi
+
+if test "$GNU_CXX"; then
+    # FIXME: Let us build with strict aliasing. bug 414641.
+    CXXFLAGS="$CXXFLAGS -fno-strict-aliasing"
+    # Turn on GNU specific features
+    _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wall -Wconversion -Wpointer-arith -Woverloaded-virtual -Wsynth -Wno-ctor-dtor-privacy -Wno-non-virtual-dtor"
+    if test -z "$INTEL_CC"; then
+       # Don't use -Wcast-align with ICC
+       case "$CPU_ARCH" in
+           # And don't use it on hppa, ia64, sparc, since it's noisy there
+           hppa | ia64 | sparc)
+           ;;
+           *)
+        _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wcast-align"
+           ;;
+       esac
+    fi
+
+    _DEFINES_CXXFLAGS='-DMOZILLA_CLIENT -include $(DEPTH)/mozilla-config.h'
+    _USE_CPP_INCLUDE_FLAG=1
+else
+    _DEFINES_CXXFLAGS='-DMOZILLA_CLIENT -D_MOZILLA_CONFIG_H_ $(ACDEFINES)'
+fi
+
+dnl gcc can come with its own linker so it is better to use the pass-thru calls
+dnl MKSHLIB_FORCE_ALL is used to force the linker to include all object
+dnl files present in an archive. MKSHLIB_UNFORCE_ALL reverts the linker to
+dnl normal behavior.
+dnl ========================================================
+MKSHLIB_FORCE_ALL=
+MKSHLIB_UNFORCE_ALL=
+
+if test "$COMPILE_ENVIRONMENT"; then
+if test "$GNU_CC"; then
+  AC_MSG_CHECKING(whether ld has archive extraction flags)
+  AC_CACHE_VAL(ac_cv_mkshlib_force_and_unforce,
+   [_SAVE_LDFLAGS=$LDFLAGS; _SAVE_LIBS=$LIBS
+    ac_cv_mkshlib_force_and_unforce="no"
+    exec 3<&0 <<LOOP_INPUT
+	force="-Wl,--whole-archive";   unforce="-Wl,--no-whole-archive"
+	force="-Wl,-z -Wl,allextract"; unforce="-Wl,-z -Wl,defaultextract"
+	force="-Wl,-all";              unforce="-Wl,-none"
+LOOP_INPUT
+    while read line
+    do
+      eval $line
+      LDFLAGS=$force
+      LIBS=$unforce
+      AC_TRY_LINK(,, ac_cv_mkshlib_force_and_unforce=$line; break)
+    done
+    exec 0<&3 3<&-
+    LDFLAGS=$_SAVE_LDFLAGS; LIBS=$_SAVE_LIBS
+   ])
+  if test "$ac_cv_mkshlib_force_and_unforce" = "no"; then
+    AC_MSG_RESULT(no)
+  else
+    AC_MSG_RESULT(yes)
+    eval $ac_cv_mkshlib_force_and_unforce
+    MKSHLIB_FORCE_ALL=$force
+    MKSHLIB_UNFORCE_ALL=$unforce
+  fi
+fi # GNU_CC
+fi # COMPILE_ENVIRONMENT
+
+dnl =================================================================
+dnl Set up and test static assertion macros used to avoid AC_TRY_RUN,
+dnl which is bad when cross compiling.
+dnl =================================================================
+if test "$COMPILE_ENVIRONMENT"; then
+configure_static_assert_macros='
+#define CONFIGURE_STATIC_ASSERT(condition) CONFIGURE_STATIC_ASSERT_IMPL(condition, __LINE__)
+#define CONFIGURE_STATIC_ASSERT_IMPL(condition, line) CONFIGURE_STATIC_ASSERT_IMPL2(condition, line)
+#define CONFIGURE_STATIC_ASSERT_IMPL2(condition, line) typedef int static_assert_line_##line[(condition) ? 1 : -1]
+'
+
+dnl test that the macros actually work:
+AC_MSG_CHECKING(that static assertion macros used in autoconf tests work)
+AC_CACHE_VAL(ac_cv_static_assertion_macros_work,
+ [AC_LANG_SAVE
+  AC_LANG_C
+  ac_cv_static_assertion_macros_work="yes"
+  AC_TRY_COMPILE([$configure_static_assert_macros],
+                 [CONFIGURE_STATIC_ASSERT(1)],
+                 ,
+                 ac_cv_static_assertion_macros_work="no")
+  AC_TRY_COMPILE([$configure_static_assert_macros],
+                 [CONFIGURE_STATIC_ASSERT(0)],
+                 ac_cv_static_assertion_macros_work="no",
+                 )
+  AC_LANG_CPLUSPLUS
+  AC_TRY_COMPILE([$configure_static_assert_macros],
+                 [CONFIGURE_STATIC_ASSERT(1)],
+                 ,
+                 ac_cv_static_assertion_macros_work="no")
+  AC_TRY_COMPILE([$configure_static_assert_macros],
+                 [CONFIGURE_STATIC_ASSERT(0)],
+                 ac_cv_static_assertion_macros_work="no",
+                 )
+  AC_LANG_RESTORE
+ ])
+AC_MSG_RESULT("$ac_cv_static_assertion_macros_work")
+if test "$ac_cv_static_assertion_macros_work" = "no"; then
+    AC_MSG_ERROR([Compiler cannot compile macros used in autoconf tests.])
+fi
+
+fi # COMPILE_ENVIRONMENT
+
+dnl ========================================================
+dnl Checking for 64-bit OS
+dnl ========================================================
+if test "$COMPILE_ENVIRONMENT"; then
+AC_LANG_SAVE
+AC_LANG_C
+AC_MSG_CHECKING(for 64-bit OS)
+AC_TRY_COMPILE([$configure_static_assert_macros],
+               [CONFIGURE_STATIC_ASSERT(sizeof(long) == 8)],
+               result="yes", result="no")
+AC_MSG_RESULT("$result")
+if test "$result" = "yes"; then
+    AC_DEFINE(HAVE_64BIT_OS)
+    HAVE_64BIT_OS=1
+fi
+AC_SUBST(HAVE_64BIT_OS)
+AC_LANG_RESTORE
+fi # COMPILE_ENVIRONMENT
+
+dnl ========================================================
+dnl Enable high-memory support on OS/2 by default.
+dnl ========================================================
+MOZ_OS2_HIGH_MEMORY=1
+MOZ_ARG_DISABLE_BOOL(os2-high-mem,
+[  --disable-os2-high-mem  Disable high-memory support on OS/2],
+    MOZ_OS2_HIGH_MEMORY=,
+    MOZ_OS2_HIGH_MEMORY=1 )
+AC_SUBST(MOZ_OS2_HIGH_MEMORY)
+
+dnl ========================================================
+dnl System overrides of the defaults for host
+dnl ========================================================
+case "$host" in
+*-beos*)
+    HOST_CFLAGS="$HOST_CFLAGS -DXP_BEOS -DBeOS -DBEOS -D_POSIX_SOURCE -DNO_X11"
+    HOST_NSPR_MDCPUCFG='\"md/_beos.cfg\"'
+    HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
+    ;;
+
+*cygwin*|*mingw*|*mks*|*msvc*|*wince)
+    if test -n "$_WIN32_MSVC"; then
+        HOST_AR=lib
+        HOST_AR_FLAGS='-NOLOGO -OUT:"$@"'
+        HOST_CFLAGS="$HOST_CFLAGS -TC -nologo -Fd\$(HOST_PDBFILE)"
+        HOST_RANLIB='echo ranlib'
+    else
+        HOST_CFLAGS="$HOST_CFLAGS -mno-cygwin"
+    fi
+    HOST_CFLAGS="$HOST_CFLAGS -DXP_WIN32 -DXP_WIN -DWIN32 -D_WIN32 -DNO_X11"
+    HOST_NSPR_MDCPUCFG='\"md/_winnt.cfg\"'
+    HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
+    HOST_BIN_SUFFIX=.exe
+    case "$host" in
+    *mingw*)
+    dnl MinGW/MSYS does not need CYGWIN_WRAPPER
+        ;;
+    *)
+        CYGWIN_WRAPPER="${srcdir}/build/cygwin-wrapper"
+        if test "`echo ${srcdir} | grep -c ^/ 2>/dev/null`" = 0; then
+            _pwd=`pwd`
+            CYGWIN_WRAPPER="${_pwd}/${srcdir}/build/cygwin-wrapper"
+        fi
+        if test "`${PERL} -v | grep -c cygwin  2>/dev/null`" = 0; then
+            AS_PERL=1
+            PERL="${CYGWIN_WRAPPER} $PERL"
+        fi
+
+        if test "`${PYTHON} -c 'import sys; print sys.platform;'`" != "cygwin"; then
+            PYTHON="${CYGWIN_WRAPPER} $PYTHON"
+        fi
+        ;;
+    esac
+    ;;
+
+*-darwin*)
+    HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX -DXP_MACOSX -DNO_X11"
+    HOST_NSPR_MDCPUCFG='\"md/_darwin.cfg\"'
+    HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
+    MOZ_FIX_LINK_PATHS='-Wl,-executable_path,$(LIBXUL_DIST)/bin'
+    LIBXUL_LIBS='$(XPCOM_FROZEN_LDOPTS) $(LIBXUL_DIST)/bin/XUL -lobjc'
+    ;;
+
+*-linux*|*-kfreebsd*-gnu)
+    HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
+    HOST_NSPR_MDCPUCFG='\"md/_linux.cfg\"'
+    HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
+    ;;
+
+*os2*)
+    HOST_CFLAGS="$HOST_CFLAGS -DXP_OS2 -DNO_X11 -Zomf"
+    HOST_NSPR_MDCPUCFG='\"md/_os2.cfg\"'
+    HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
+    HOST_BIN_SUFFIX=.exe
+    MOZ_FIX_LINK_PATHS=
+    ;;
+
+*-osf*)
+    HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
+    HOST_NSPR_MDCPUCFG='\"md/_osf1.cfg\"'
+    HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
+    ;;
+
+*)
+    HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
+    HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
+    ;;
+esac
+
+dnl Get mozilla version from central milestone file
+MOZILLA_VERSION=`$PERL $MOZILLA_SRCDIR/config/milestone.pl -topsrcdir $MOZILLA_SRCDIR`
+
+dnl Get version of various core apps from the version files.
+THUNDERBIRD_VERSION=`cat $topsrcdir/mail/config/version.txt`
+SUNBIRD_VERSION=`cat $topsrcdir/calendar/sunbird/config/version.txt`
+SEAMONKEY_VERSION=`cat $topsrcdir/suite/config/version.txt`
+
+AC_DEFINE_UNQUOTED(MOZILLA_VERSION,"$MOZILLA_VERSION")
+AC_DEFINE_UNQUOTED(MOZILLA_VERSION_U,$MOZILLA_VERSION)
+
+dnl ========================================================
+dnl System overrides of the defaults for target
+dnl ========================================================
+
+case "$target" in
+*-aix*)
+    AC_DEFINE(AIX)
+    if test ! "$GNU_CC"; then
+        if test ! "$HAVE_64BIT_OS"; then
+            # Compiling with Visual Age C++ object model compat is the
+            # default. To compile with object model ibm, add 
+            # AIX_OBJMODEL=ibm to .mozconfig.
+            if test "$AIX_OBJMODEL" = "ibm"; then
+                CXXFLAGS="$CXXFLAGS -qobjmodel=ibm"
+            else
+                AIX_OBJMODEL=compat
+            fi
+        else
+            AIX_OBJMODEL=compat
+        fi
+        AC_SUBST(AIX_OBJMODEL)
+        DSO_LDOPTS='-qmkshrobj=1'
+        DSO_CFLAGS='-qflag=w:w'
+        DSO_PIC_CFLAGS=
+        LDFLAGS="$LDFLAGS -Wl,-brtl -blibpath:/usr/lib:/lib"
+        AC_MSG_WARN([Clearing MOZ_FIX_LINK_PATHS till we can fix bug 332075.])
+        MOZ_FIX_LINK_PATHS=
+        MKSHLIB='$(CXX) $(DSO_LDOPTS) -o $@'
+        MKCSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
+        if test "$COMPILE_ENVIRONMENT"; then
+            AC_LANG_SAVE
+            AC_LANG_CPLUSPLUS
+            AC_MSG_CHECKING([for VisualAge C++ compiler version >= 5.0.2.0])
+            AC_TRY_COMPILE([],
+                [#if (__IBMCPP__ < 502)
+                 #error "Bad compiler"
+                 #endif],
+                _BAD_COMPILER=,_BAD_COMPILER=1)
+            if test -n "$_BAD_COMPILER"; then
+                AC_MSG_RESULT([no])    
+                AC_MSG_ERROR([VisualAge C++ version 5.0.2.0 or higher is required to build.])
+            else
+                AC_MSG_RESULT([yes])    
+            fi
+            AC_LANG_RESTORE
+            TARGET_COMPILER_ABI="ibmc"
+            CC_VERSION=`lslpp -Lcq vac.C 2>/dev/null | awk -F: '{ print $3 }'`
+            CXX_VERSION=`lslpp -Lcq vacpp.cmp.core 2>/dev/null | awk -F: '{ print $3 }'`
+        fi
+    fi
+    case "${target_os}" in
+    aix4.1*)
+        DLL_SUFFIX='_shr.a'
+        ;;
+    esac
+    if test "$COMPILE_ENVIRONMENT"; then
+        AC_CHECK_HEADERS(sys/inttypes.h)
+    fi
+    AC_DEFINE(NSCAP_DISABLE_DEBUG_PTR_TYPES)
+    ;;
+
+*-beos*)
+    no_x=yes
+    MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_LDOPTS) -Wl,-h,$@ -o $@'
+    _PLATFORM_DEFAULT_TOOLKIT="cairo-beos"
+    DSO_LDOPTS='-nostart'
+    TK_LIBS='-lbe -lroot'
+    LIBS="$LIBS -lbe"
+    if test "$COMPILE_ENVIRONMENT"; then
+        AC_CHECK_LIB(bind,main,LIBS="$LIBS -lbind")
+        AC_CHECK_LIB(zeta,main,LIBS="$LIBS -lzeta")
+    fi
+    _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wno-multichar"
+    _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wno-multichar"
+    _MOZ_USE_RTTI=1
+    USE_DEPENDENT_LIBS=
+    MOZ_USER_DIR="Mozilla"
+    ;;
+
+*-bsdi*)
+    dnl -pedantic doesn't play well with BSDI's _very_ modified gcc (shlicc2)
+    _PEDANTIC=
+    _IGNORE_LONG_LONG_WARNINGS=
+    case $OS_RELEASE in
+	4.*|5.*)
+            STRIP="$STRIP -d"
+            ;;
+	*)
+	    DSO_CFLAGS=''
+	    DSO_LDOPTS='-r'
+	    _WARNINGS_CFLAGS="-Wall"
+	    _WARNINGS_CXXFLAGS="-Wall"
+	    # The test above doesn't work properly, at least on 3.1.
+	    MKSHLIB_FORCE_ALL=''
+	    MKSHLIB_UNFORCE_ALL=''
+	;;
+    esac
+    ;;
+
+*-darwin*) 
+    MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@'
+    MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@'
+    MOZ_OPTIMIZE_FLAGS="-O2"
+    _PEDANTIC=
+    CFLAGS="$CFLAGS -fpascal-strings -fno-common"
+    CXXFLAGS="$CXXFLAGS -fpascal-strings -fno-common"
+    DLL_SUFFIX=".dylib"
+    DSO_LDOPTS=''
+    STRIP="$STRIP -x -S"
+    _PLATFORM_DEFAULT_TOOLKIT='cairo-cocoa'
+    MOZ_ENABLE_POSTSCRIPT=
+    TARGET_NSPR_MDCPUCFG='\"md/_darwin.cfg\"'
+    LDFLAGS="$LDFLAGS -framework Cocoa"
+    # The ExceptionHandling framework is needed for Objective-C exception
+    # logging code in nsObjCExceptions.h. Currently we only use that in debug
+    # builds.
+    MOZ_DEBUG_LDFLAGS="$MOZ_DEBUG_LDFLAGS -framework ExceptionHandling"
+    # set MACOSX to generate lib/mac/MoreFiles/Makefile
+    MACOSX=1
+
+    dnl DTrace and -dead_strip don't interact well. See bug 403132.
+    dnl ===================================================================
+    if test "x$enable_dtrace" = "xyes"; then
+        echo "Skipping -dead_strip because DTrace is enabled. See bug 403132."
+    else
+        dnl check for the presence of the -dead_strip linker flag
+        AC_MSG_CHECKING([for -dead_strip option to ld])
+        _SAVE_LDFLAGS=$LDFLAGS
+        LDFLAGS="$LDFLAGS -Wl,-dead_strip"
+        AC_TRY_LINK(,[return 0;],_HAVE_DEAD_STRIP=1,_HAVE_DEAD_STRIP=)
+        if test -n "$_HAVE_DEAD_STRIP" ; then
+            AC_MSG_RESULT([yes])
+            MOZ_OPTIMIZE_LDFLAGS="-Wl,-dead_strip"
+        else
+            AC_MSG_RESULT([no])
+        fi
+        
+        LDFLAGS=$_SAVE_LDFLAGS
+    fi
+    ;;
+
+*-freebsd*)
+    if test `test -x /usr/bin/objformat && /usr/bin/objformat || echo elf` != "elf"; then
+	DLL_SUFFIX=".so.1.0"
+	DSO_LDOPTS="-shared"
+    fi
+    if test ! "$GNU_CC"; then
+	DSO_LDOPTS="-Bshareable $DSO_LDOPTS"
+    fi
+# Can't have force w/o an unforce.
+#    # Hack for FreeBSD 2.2
+#    if test -z "$MKSHLIB_FORCE_ALL"; then
+#	MKSHLIB_FORCE_ALL='-Wl,-Bforcearchive'
+#	MKSHLIB_UNFORCE_ALL=''
+#    fi
+    ;; 
+
+*-hpux*)
+    DLL_SUFFIX=".sl"
+    if test ! "$GNU_CC"; then
+    	DSO_LDOPTS='-b -Wl,+s'
+    	DSO_CFLAGS=""
+    	DSO_PIC_CFLAGS="+Z"
+    	MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_LDOPTS) -L$(LIBXUL_DIST)/bin -o $@'
+    	MKCSHLIB='$(LD) -b +s -L$(LIBXUL_DIST)/bin -o $@'
+        CXXFLAGS="$CXXFLAGS -Wc,-ansi_for_scope,on"
+    else
+        DSO_LDOPTS='-b -E +s'
+        MKSHLIB='$(LD) $(DSO_LDOPTS) -L$(LIBXUL_DIST)/bin -L$(LIBXUL_DIST)/lib -o $@'
+        MKCSHLIB='$(LD) $(DSO_LDOPTS) -L$(LIBXUL_DIST)/bin -L$(LIBXUL_DIST)/lib -o $@'
+    fi
+    MOZ_POST_PROGRAM_COMMAND='chatr +s enable'
+    AC_DEFINE(NSCAP_DISABLE_DEBUG_PTR_TYPES)
+    ;;
+
+*-irix5*)
+    AC_DEFINE(IRIX)
+    DSO_LDOPTS='-elf -shared'
+
+    if test "$GNU_CC"; then
+       MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@'
+       MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@'
+       MKSHLIB_FORCE_ALL='-Wl,-all'
+       MKSHLIB_UNFORCE_ALL='-Wl,-none'
+       CXXFLAGS="$CXXFLAGS -D_LANGUAGE_C_PLUS_PLUS"
+    else
+       MKSHLIB='$(LD) $(DSO_LDOPTS) -o $@'
+       MKCSHLIB='$(LD) $(DSO_LDOPTS) -o $@'
+       MKSHLIB_FORCE_ALL='-all'
+       MKSHLIB_UNFORCE_ALL='-none'
+    fi
+    ;;
+
+*-irix6*)
+    AC_DEFINE(IRIX)
+    dnl the irix specific xptcinvoke code is written against the n32 ABI so we *must* 
+    dnl compile and link using -n32
+    USE_N32=1
+    TARGET_COMPILER_ABI=n32
+    DSO_LDOPTS='-elf -shared'
+    MKSHLIB='$(CCC) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@'
+    MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@'
+    _MOZ_EXCEPTIONS_FLAGS_OFF="-LANG:exceptions=OFF"
+    _MOZ_EXCEPTIONS_FLAGS_ON="-LANG:exceptions=ON"
+    if test "$GNU_CC"; then
+       MKSHLIB_FORCE_ALL='-Wl,-all'
+       MKSHLIB_UNFORCE_ALL='-Wl,-none'
+       _WARNINGS_CFLAGS="-Wall"
+       _WARNINGS_CXXFLAGS="-Wall"
+       CXXFLAGS="$CXXFLAGS -D_LANGUAGE_C_PLUS_PLUS"
+    else
+       MKSHLIB_FORCE_ALL='-all'
+       MKSHLIB_UNFORCE_ALL='-none'
+	   AR_LIST="$AR t"
+	   AR_EXTRACT="$AR x"
+	   AR_DELETE="$AR d"
+	   AR='$(CXX) -ar'
+	   AR_FLAGS='-o $@'
+       CFLAGS="$CFLAGS -woff 3262 -G 4"
+       CXXFLAGS="$CXXFLAGS -woff 3262 -G 4"
+       if test -n "$USE_N32"; then
+	   ASFLAGS="$ASFLAGS -n32"
+	   CFLAGS="$CFLAGS -n32"
+	   CXXFLAGS="$CXXFLAGS -n32"
+	   LDFLAGS="$LDFLAGS -n32"
+       fi
+       AC_DEFINE(NSCAP_DISABLE_DEBUG_PTR_TYPES)
+       AC_MSG_WARN([Clearing MOZ_FIX_LINK_PATHS for OSF/1 as fix for bug 333545 (till the reference bug 332075 is fixed.])
+       MOZ_FIX_LINK_PATHS=
+    fi
+    if test -z "$GNU_CXX"; then
+      MIPSPRO_CXX=1
+    fi
+    ;;
+
+*-*linux*)
+    if test "$GNU_CC"; then
+        GCC_VERSION=`$CC -v 2>&1 | awk '/^gcc version/ { print $3 }'`
+        case $GCC_VERSION in
+        4.1.*|4.2.*)
+            # -Os is broken on gcc 4.1.x and 4.2.x, we need to tweak it to get good results.
+            MOZ_OPTIMIZE_SIZE_TWEAK="-finline-limit=50"
+        esac
+    fi
+
+    TARGET_NSPR_MDCPUCFG='\"md/_linux.cfg\"'
+    MOZ_OPTIMIZE_FLAGS="-Os -freorder-blocks -fno-reorder-functions $MOZ_OPTIMIZE_SIZE_TWEAK"
+    MOZ_DEBUG_FLAGS="-g -fno-inline"  # most people on linux use gcc/gdb,
+                                      # and that combo is not yet good at
+                                      # debugging inlined functions (even
+                                      # when using DWARF2 as the debugging
+                                      # format)    
+
+    MOZ_MEMORY=1
+
+    case "${target_cpu}" in
+    alpha*)
+    	CFLAGS="$CFLAGS -mieee"
+    	CXXFLAGS="$CXXFLAGS -mieee"
+    ;;
+    i*86)
+    	USE_ELF_DYNSTR_GC=1
+        MOZ_ENABLE_OLD_ABI_COMPAT_WRAPPERS=1
+    ;;
+    mips*)
+        CFLAGS="$CFLAGS -Wa,-xgot"
+        CXXFLAGS="$CXXFLAGS -Wa,-xgot"
+    ;;
+    esac
+    ;;
+
+*-wince*)
+
+    MOZ_TOOLS_DIR=`echo $MOZ_TOOLS`
+    AR_LIST="$AR -list"
+    AR_EXTRACT="$AR -extract"
+    AR_DELETE="$AR d"
+    AR_FLAGS='-OUT:"$@"'
+
+    DSO_CFLAGS=
+    DSO_PIC_CFLAGS=
+    DLL_SUFFIX=.dll
+    BIN_SUFFIX='.exe'
+    RC=rc.exe
+    # certain versions of cygwin's makedepend barf on the 
+    # #include <string> vs -I./dist/include/string issue so don't use it
+    SYSTEM_MAKEDEPEND=
+
+    HOST_CC=cl
+    HOST_CXX=cl
+    HOST_LD=link
+    HOST_AR='lib -OUT:$@'
+    HOST_RANLIB='echo ranlib'
+    HOST_CFLAGS="$HOST_CFLAGS -D_X86_"
+        
+        
+    WARNINGS_AS_ERRORS='-WX'
+	MOZ_OPTIMIZE_FLAGS='-O1'
+    AR_FLAGS='-NOLOGO -OUT:"$@"'
+    ASM_SUFFIX=asm
+    CFLAGS="$CFLAGS -W3 -Gy -Fd\$(PDBFILE)"
+    CXXFLAGS="$CXXFLAGS -W3 -Gy -Fd\$(PDBFILE)"
+    DLL_PREFIX=
+    DOXYGEN=:
+    DSO_LDOPTS=-SUBSYSTEM:WINDOWSCE
+    DYNAMIC_XPCOM_LIBS='$(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/xpcom_core.lib'
+    GARBAGE=
+    IMPORT_LIB_SUFFIX=lib
+    LIBS="$LIBS"
+    LIBXUL_LIBS='$(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/xul.lib'
+    LIB_PREFIX=
+    LIB_SUFFIX=lib 
+    MKCSHLIB='$(LD) -NOLOGO -DLL -OUT:$@ $(DSO_LDOPTS)'
+    MKSHLIB='$(LD) -NOLOGO -DLL -OUT:$@ $(DSO_LDOPTS)'
+    MKSHLIB_FORCE_ALL=
+    MKSHLIB_UNFORCE_ALL=
+    MOZ_COMPONENT_NSPR_LIBS='$(NSPR_LIBS)'
+    MOZ_COMPONENT_NSPR_LIBS='$(NSPR_LIBS)'
+    MOZ_DEBUG_FLAGS='-Zi'
+    MOZ_DEBUG_LDFLAGS='-DEBUG -DEBUGTYPE:CV'
+    MOZ_FIX_LINK_PATHS=
+    MOZ_JS_LIBS='$(LIBXUL_DIST)/lib/js$(MOZ_BITS)$(VERSION_NUMBER).lib'
+    MOZ_XPCOM_OBSOLETE_LIBS='$(LIBXUL_DIST)/lib/xpcom_compat.lib'
+    OBJ_SUFFIX=obj
+    RANLIB='echo not_ranlib'
+    STRIP='echo not_strip'
+    TARGET_NSPR_MDCPUCFG='\"md/_wince.cfg\"'
+    UNZIP=unzip
+    XARGS=xargs
+    XPCOM_FROZEN_LDOPTS='$(LIBXUL_DIST)/lib/xpcom.lib'
+    ZIP=zip
+    LIBIDL_CFLAGS="-I$MOZ_TOOLS_DIR/include ${GLIB_CFLAGS}"
+    LIBIDL_LIBS="$MOZ_TOOLS_DIR/lib/libidl-0.6_s.lib $MOZ_TOOLS_DIR/lib/glib-1.2_s.lib"
+    STATIC_LIBIDL=1
+
+    AC_DEFINE(HAVE_SNPRINTF)
+    AC_DEFINE(_WINDOWS)
+    AC_DEFINE(_WIN32)
+    AC_DEFINE(WIN32)
+    AC_DEFINE(XP_WIN)
+    AC_DEFINE(XP_WIN32)
+    AC_DEFINE(HW_THREADS)
+    AC_DEFINE(STDC_HEADERS)
+    AC_DEFINE(NEW_H, <new>)
+    AC_DEFINE(WIN32_LEAN_AND_MEAN)
+
+    TARGET_MD_ARCH=win32
+    _PLATFORM_DEFAULT_TOOLKIT='windows'
+    BIN_SUFFIX='.exe'
+    USE_SHORT_LIBNAME=1
+    MOZ_ENABLE_POSTSCRIPT=
+    MOZ_USER_DIR="Mozilla"
+;;
+
+
+*-mingw*|*-cygwin*|*-msvc*|*-mks*)
+    DSO_CFLAGS=
+    DSO_PIC_CFLAGS=
+    DLL_SUFFIX=.dll
+    RC=rc.exe
+    # certain versions of cygwin's makedepend barf on the 
+    # #include <string> vs -I./dist/include/string issue so don't use it
+    SYSTEM_MAKEDEPEND=
+    if test -n "$GNU_CC"; then
+        CC="$CC -mno-cygwin"
+        CXX="$CXX -mno-cygwin"
+        CPP="$CPP -mno-cygwin"
+        CFLAGS="$CFLAGS -mms-bitfields"
+        CXXFLAGS="$CXXFLAGS -mms-bitfields"
+        DSO_LDOPTS='-shared'
+        MKSHLIB='$(CXX) $(DSO_LDOPTS) -o $@'
+        MKCSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
+        RC='$(WINDRES)'
+        # Use temp file for windres (bug 213281)
+        RCFLAGS='-O coff --use-temp-file'
+        # mingw doesn't require kernel32, user32, and advapi32 explicitly
+        LIBS="$LIBS -lgdi32 -lwinmm -lwsock32"
+        MOZ_JS_LIBS='-L$(LIBXUL_DIST)/lib -ljs$(MOZ_BITS)$(VERSION_NUMBER)'
+        MOZ_FIX_LINK_PATHS=
+        DYNAMIC_XPCOM_LIBS='-L$(LIBXUL_DIST)/lib -lxpcom -lxpcom_core'
+        XPCOM_FROZEN_LDOPTS='-L$(LIBXUL_DIST)/lib -lxpcom'
+        DLL_PREFIX=
+        IMPORT_LIB_SUFFIX=dll.a
+    else
+        TARGET_COMPILER_ABI=msvc
+        HOST_CC='$(CC)'
+        HOST_CXX='$(CXX)'
+        HOST_LD='$(LD)'
+        AR='lib -NOLOGO -OUT:"$@"'
+        AR_FLAGS=
+        RANLIB='echo not_ranlib'
+        STRIP='echo not_strip'
+        XARGS=xargs
+        ZIP=zip
+        UNZIP=unzip
+        DOXYGEN=:
+        GARBAGE='$(OBJDIR)/vc20.pdb $(OBJDIR)/vc40.pdb'
+        OBJ_SUFFIX=obj
+        LIB_SUFFIX=lib
+        DLL_PREFIX=
+        LIB_PREFIX=
+        IMPORT_LIB_SUFFIX=lib
+        MKSHLIB='$(LD) -NOLOGO -DLL -OUT:$@ -PDB:$(PDBFILE) $(DSO_LDOPTS)'
+        MKCSHLIB='$(LD) -NOLOGO -DLL -OUT:$@ -PDB:$(PDBFILE) $(DSO_LDOPTS)'
+        MKSHLIB_FORCE_ALL=
+        MKSHLIB_UNFORCE_ALL=
+        DSO_LDOPTS=-SUBSYSTEM:WINDOWS
+        CFLAGS="$CFLAGS -W3 -Gy -Fd\$(PDBFILE)"
+        CXXFLAGS="$CXXFLAGS -W3 -Gy -Fd\$(PDBFILE)"
+        LIBS="$LIBS kernel32.lib user32.lib gdi32.lib winmm.lib wsock32.lib advapi32.lib"
+        MOZ_DEBUG_FLAGS='-Zi'
+        MOZ_DEBUG_LDFLAGS='-DEBUG -DEBUGTYPE:CV'
+        WARNINGS_AS_ERRORS='-WX'
+    	MOZ_OPTIMIZE_FLAGS='-O1'
+        MOZ_JS_LIBS='$(LIBXUL_DIST)/lib/js$(MOZ_BITS)$(VERSION_NUMBER).lib'
+        MOZ_FIX_LINK_PATHS=
+        DYNAMIC_XPCOM_LIBS='$(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/xpcom_core.lib'
+        XPCOM_FROZEN_LDOPTS='$(LIBXUL_DIST)/lib/xpcom.lib'
+        LIBXUL_LIBS='$(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/xul.lib'
+        MOZ_COMPONENT_NSPR_LIBS='$(NSPR_LIBS)'
+        MOZ_XPCOM_OBSOLETE_LIBS='$(LIBXUL_DIST)/lib/xpcom_compat.lib'
+        if test $_MSC_VER -ge 1400; then
+            LDFLAGS="$LDFLAGS -NXCOMPAT -SAFESEH"
+            dnl For profile-guided optimization
+            PROFILE_GEN_CFLAGS="-GL"
+            PROFILE_GEN_LDFLAGS="-LTCG:PGINSTRUMENT"
+            dnl XXX: PGO builds can fail with warnings treated as errors,
+            dnl specifically "no profile data available" appears to be
+            dnl treated as an error sometimes. This might be a consequence
+            dnl of using WARNINGS_AS_ERRORS in some modules, combined
+            dnl with the linker doing most of the work in the whole-program
+            dnl optimization/PGO case. I think it's probably a compiler bug,
+            dnl but we work around it here.
+            PROFILE_USE_CFLAGS="-GL -wd4624 -wd4952"
+            dnl XXX: should be -LTCG:PGOPTIMIZE, but that fails on libxul.
+            dnl Probably also a compiler bug, but what can you do?
+            PROFILE_USE_LDFLAGS="-LTCG:PGUPDATE"
+            if test -n "$_USE_DYNAMICBASE"; then
+               LDFLAGS="$LDFLAGS -DYNAMICBASE"
+            fi
+        fi
+    fi
+    MOZ_JPEG_LIBS='$(call EXPAND_LIBNAME_PATH,jpeg$(MOZ_BITS)$(VERSION_NUMBER),$(DEPTH)/mozilla/jpeg)'
+    MOZ_PNG_LIBS='$(call EXPAND_LIBNAME_PATH,png,$(DEPTH)/mozilla/modules/libimg/png)'
+    AC_DEFINE(HAVE_SNPRINTF)
+    AC_DEFINE(_WINDOWS)
+    AC_DEFINE(_WIN32)
+    AC_DEFINE(WIN32)
+    AC_DEFINE(XP_WIN)
+    AC_DEFINE(XP_WIN32)
+    AC_DEFINE(HW_THREADS)
+    AC_DEFINE(STDC_HEADERS)
+    AC_DEFINE(NEW_H, <new>)
+    AC_DEFINE(WIN32_LEAN_AND_MEAN)
+    TARGET_MD_ARCH=win32
+    _PLATFORM_DEFAULT_TOOLKIT='cairo-windows'
+    BIN_SUFFIX='.exe'
+    USE_SHORT_LIBNAME=1
+    MOZ_ENABLE_POSTSCRIPT=
+    MOZ_USER_DIR="Mozilla"
+
+    dnl Hardcode to win95 for now - cls
+    TARGET_NSPR_MDCPUCFG='\"md/_win95.cfg\"'
+
+    dnl set NO_X11 defines here as the general check is skipped on win32
+    no_x=yes
+    AC_DEFINE(NO_X11)
+
+    dnl MinGW/MSYS doesn't provide or need cygpath
+    case "$host" in
+    *-mingw*)
+	CYGPATH_W=echo
+	CYGPATH_S=cat
+	MOZ_BUILD_ROOT=`cd $MOZ_BUILD_ROOT && pwd -W`
+	;;
+    *-cygwin*|*-msvc*|*-mks*)
+	CYGPATH_W="cygpath -a -w"
+	CYGPATH_S="sed -e s|\\\\|/|g"
+	MOZ_BUILD_ROOT=`$CYGPATH_W $MOZ_BUILD_ROOT | $CYGPATH_S`
+	;;
+    esac
+    case "$host" in
+    *-mingw*|*-cygwin*|*-msvc*|*-mks*)
+
+    if test -z "$MOZ_TOOLS"; then
+        AC_MSG_ERROR([MOZ_TOOLS is not set])
+    fi
+
+    MOZ_TOOLS_DIR=`cd $MOZ_TOOLS && pwd`
+    if test "$?" != "0" || test -z "$MOZ_TOOLS_DIR"; then
+        AC_MSG_ERROR([cd \$MOZ_TOOLS failed. MOZ_TOOLS ==? $MOZ_TOOLS])
+    fi
+    if test `echo ${PATH}: | grep -ic "$MOZ_TOOLS_DIR/bin:"` = 0; then
+        AC_MSG_ERROR([\$MOZ_TOOLS\\bin must be in your path.])
+    fi
+    MOZ_TOOLS_DIR=`$CYGPATH_W $MOZ_TOOLS_DIR | $CYGPATH_S`
+
+    if test -n "$GLIB_PREFIX"; then
+        _GLIB_PREFIX_DIR=`cd $GLIB_PREFIX && pwd`
+        if test "$?" = "0"; then
+            if test `echo ${PATH}: | grep -ic "$_GLIB_PREFIX_DIR/bin:"` = 0; then
+                AC_MSG_ERROR([GLIB_PREFIX must be in your \$PATH.])
+            fi
+            _GLIB_PREFIX_DIR=`$CYGPATH_W $_GLIB_PREFIX_DIR | $CYGPATH_S`
+        else
+            AC_MSG_ERROR([GLIB_PREFIX is set but "${GLIB_PREFIX}" is not a directory.])
+        fi
+    else
+        _GLIB_PREFIX_DIR=$MOZ_TOOLS_DIR
+    fi
+    if test ! -f "${_GLIB_PREFIX_DIR}/include/glib.h"; then
+        AC_MSG_ERROR([Cannot find $_GLIB_PREFIX_DIR/include/glib.h .])
+    fi
+    GLIB_CFLAGS="-I${_GLIB_PREFIX_DIR}/include"
+    if test -f "${_GLIB_PREFIX_DIR}/lib/glib-1.2_s.lib"; then
+        GLIB_LIBS="${_GLIB_PREFIX_DIR}/lib/glib-1.2_s.lib"
+    elif test -f "${_GLIB_PREFIX_DIR}/lib/glib-1.2.lib"; then
+        GLIB_LIBS="${_GLIB_PREFIX_DIR}/lib/glib-1.2.lib"
+    else
+        AC_MSG_ERROR([Cannot find $_GLIB_PREFIX_DIR/lib/glib-1.2.lib or $_GLIB_PREFIX_DIR/lib/glib-1.2_s.lib])
+    fi
+
+    if test -n "$LIBIDL_PREFIX"; then
+        _LIBIDL_PREFIX_DIR=`cd $LIBIDL_PREFIX && pwd`
+        if test "$?" = "0"; then
+            if test `echo ${PATH}: | grep -ic "$_LIBIDL_PREFIX_DIR/bin:"` = 0; then
+                AC_MSG_ERROR([LIBIDL_PREFIX must be in your \$PATH.])
+            fi
+            _LIBIDL_PREFIX_DIR=`$CYGPATH_W $_LIBIDL_PREFIX_DIR | $CYGPATH_S`
+        else
+            AC_MSG_ERROR([LIBIDL_PREFIX is set but "${LIBIDL_PREFIX}" is not a directory.])
+        fi
+    else
+        _LIBIDL_PREFIX_DIR=$MOZ_TOOLS_DIR
+    fi        
+    if test ! -f "${_LIBIDL_PREFIX_DIR}/include/libIDL/IDL.h"; then
+        AC_MSG_ERROR([Cannot find $_LIBIDL_PREFIX_DIR/include/libIDL/IDL.h .])
+    fi
+    LIBIDL_CFLAGS="-I${_LIBIDL_PREFIX_DIR}/include ${GLIB_CFLAGS}"
+    if test -f "${_LIBIDL_PREFIX_DIR}/lib/libidl-0.6_s.lib"; then
+        LIBIDL_LIBS="${_LIBIDL_PREFIX_DIR}/lib/libidl-0.6_s.lib"
+        STATIC_LIBIDL=1
+    elif test -f "${_LIBIDL_PREFIX_DIR}/lib/libidl-0.6.lib"; then
+        LIBIDL_LIBS="${_LIBIDL_PREFIX_DIR}/lib/libidl-0.6.lib"
+    else
+        AC_MSG_ERROR([Cannot find $_LIBIDL_PREFIX_DIR/lib/libidl-0.6.lib or $_LIBIDL_PREFIX_DIR/lib/libidl-0.6_s.lib])
+    fi
+    LIBIDL_LIBS="${LIBIDL_LIBS} ${GLIB_LIBS}"
+    ;;
+
+    *) # else cross-compiling
+        if test -n "$GLIB_PREFIX"; then
+            GLIB_CFLAGS="-I${GLIB_PREFIX}/include"
+            if test -f "${GLIB_PREFIX}/lib/glib-1.2_s.lib"; then
+                GLIB_LIBS="${GLIB_PREFIX}/lib/glib-1.2_s.lib"
+            elif test -f "${GLIB_PREFIX}/lib/glib-1.2.lib"; then
+                GLIB_LIBS="${GLIB_PREFIX}/lib/glib-1.2.lib"
+            else
+                AC_MSG_ERROR([Cannot find $GLIB_PREFIX/lib/glib-1.2.lib or $GLIB_PREFIX/lib/glib-1.2_s.lib])
+            fi
+        fi
+        if test -n "$LIBIDL_PREFIX"; then
+            LIBIDL_CFLAGS="-I${LIBIDL_PREFIX}/include ${GLIB_CFLAGS}"
+            if test -f "${LIBIDL_PREFIX}/lib/libIDL-0.6_s.lib"; then
+                LIBIDL_LIBS="${LIBIDL_PREFIX}/lib/libIDL-0.6_s.lib"
+                STATIC_LIBIDL=1
+            elif test -f "${LIBIDL_PREFIX}/lib/libIDL-0.6.lib"; then
+                LIBIDL_LIBS="${LIBIDL_PREFIX}/lib/libIDL-0.6.lib"
+            else
+                AC_MSG_ERROR([Cannot find $LIBIDL_PREFIX/lib/libIDL-0.6.lib or $LIBIDL_PREFIX/lib/libIDL-0.6_s.lib])
+            fi
+        fi
+        LIBIDL_LIBS="${LIBIDL_LIBS} ${GLIB_LIBS}"
+        ;;
+    esac 
+
+
+    case "$host_os" in
+    cygwin*|msvc*|mks*)
+        AC_MSG_WARN([Using a cygwin build environment is unsupported. Configure cannot check for the presence of necessary headers. Please upgrade to MozillaBuild; see http://developer.mozilla.org/en/docs/Windows_Build_Prerequisites])
+        ;;
+
+    *)
+        AC_CHECK_HEADERS(mmintrin.h oleacc.idl)
+
+        AC_LANG_SAVE
+        AC_LANG_CPLUSPLUS
+        AC_CHECK_HEADERS(atlbase.h wpcapi.h)
+        AC_LANG_RESTORE
+        ;;
+    esac
+
+    case "$target" in
+    i*86-*)
+    	AC_DEFINE(_X86_)
+	;;
+    alpha-*)
+    	AC_DEFINE(_ALPHA_)
+	;;
+    mips-*)
+    	AC_DEFINE(_MIPS_)
+	;;
+    *)
+    	AC_DEFINE(_CPU_ARCH_NOT_DEFINED)
+	;;
+    esac
+    ;;
+
+*-netbsd*)
+    DSO_CFLAGS=''
+    CFLAGS="$CFLAGS -Dunix"
+    CXXFLAGS="$CXXFLAGS -Dunix"
+    if $CC -E - -dM </dev/null | grep __ELF__ >/dev/null; then
+        DLL_SUFFIX=".so"
+        DSO_PIC_CFLAGS='-fPIC -DPIC'
+        DSO_LDOPTS='-shared'
+	BIN_FLAGS='-Wl,--export-dynamic'
+    else
+    	DSO_PIC_CFLAGS='-fPIC -DPIC'
+    	DLL_SUFFIX=".so.1.0"
+    	DSO_LDOPTS='-shared'
+    fi
+    # This will fail on a.out systems prior to 1.5.1_ALPHA.
+    MKSHLIB_FORCE_ALL='-Wl,--whole-archive'
+    MKSHLIB_UNFORCE_ALL='-Wl,--no-whole-archive'
+    if test "$LIBRUNPATH"; then
+	DSO_LDOPTS="-Wl,-R$LIBRUNPATH $DSO_LDOPTS"
+    fi
+    MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-soname,lib$(LIBRARY_NAME)$(DLL_SUFFIX) -o $@'
+    MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-soname,lib$(LIBRARY_NAME)$(DLL_SUFFIX) -o $@'
+    ;;
+
+*-nto*) 
+	AC_DEFINE(NTO)	
+	AC_DEFINE(_QNX_SOURCE)
+	AC_DEFINE(_i386)
+	OS_TARGET=NTO
+	WARNINGS_AS_ERRORS=''
+	MOZ_OPTIMIZE_FLAGS="-O"
+	MOZ_DEBUG_FLAGS="-gstabs"
+	USE_PTHREADS=1
+	_PEDANTIC=
+	LIBS="$LIBS -lsocket -lstdc++"
+	_DEFINES_CFLAGS='-Wp,-include -Wp,$(DEPTH)/mozilla-config.h -DMOZILLA_CLIENT -D_POSIX_C_SOURCE=199506'
+	_DEFINES_CXXFLAGS='-DMOZILLA_CLIENT -Wp,-include -Wp,$(DEPTH)/mozilla-config.h -D_POSIX_C_SOURCE=199506'
+	if test "$with_x" != "yes"
+	then
+		_PLATFORM_DEFAULT_TOOLKIT="photon"
+	    TK_CFLAGS='-I/usr/include/photon'
+		TK_LIBS='-lph'
+	fi
+	case "${target_cpu}" in
+	ppc*)
+	AC_DEFINE(HAVE_VA_LIST_AS_ARRAY)	
+	;;
+	esac
+	case "${host_cpu}" in
+	i*86)
+	USE_ELF_DYNSTR_GC=1
+	;;
+	esac
+	;;
+
+*-openbsd*)
+    DLL_SUFFIX=".so.1.0"
+    DSO_CFLAGS=''
+    DSO_PIC_CFLAGS='-fPIC'
+    DSO_LDOPTS='-shared -fPIC'
+    if test "$LIBRUNPATH"; then
+	DSO_LDOPTS="-R$LIBRUNPATH $DSO_LDOPTS"
+    fi
+    ;;
+
+*-openvms*) 
+    AC_DEFINE(NO_PW_GECOS)
+    AC_DEFINE(NO_UDSOCK)
+    AC_DEFINE(POLL_WITH_XCONNECTIONNUMBER)
+    USE_PTHREADS=1
+    MKSHLIB_FORCE_ALL='-all'
+    MKSHLIB_UNFORCE_ALL='-none'
+    AS='as'
+    AS_DASH_C_FLAG='-Wc/names=as_is'
+    AR_FLAGS='c $@'
+    DSO_LDOPTS='-shared -auto_symvec'
+    DSO_PIC_CFLAGS=
+    MOZ_DEBUG_LDFLAGS='-g'
+    COMPAQ_CXX=1
+    CC_VERSION=`$CC -V 2>&1 | awk '/ C / { print $3 }'`
+    CXX_VERSION=`$CXX -V 2>&1 | awk '/ C\+\+ / { print $3 }'`
+    ;;
+
+
+*-os2*)
+    MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@'
+    MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@'
+    AC_DEFINE(XP_OS2)
+    USE_SHORT_LIBNAME=1
+    DLL_PREFIX=
+    LIB_PREFIX=
+    LIB_SUFFIX=lib
+    BIN_SUFFIX=".exe"
+    DLL_SUFFIX=".dll"
+    IMPORT_LIB_SUFFIX=lib
+    DSO_PIC_CFLAGS=
+    TARGET_MD_ARCH=os2
+    _PLATFORM_DEFAULT_TOOLKIT="cairo-os2"
+    MOZ_ENABLE_POSTSCRIPT=
+    RC=rc.exe
+    RCFLAGS='-n'
+    MOZ_USER_DIR="Mozilla"
+
+    if test "$MOZTOOLS"; then
+        MOZ_TOOLS_DIR=`echo $MOZTOOLS | sed -e 's|\\\\|/|g'`
+    else
+        AC_MSG_ERROR([MOZTOOLS is not set])
+    fi
+
+    # EMX/GCC build
+    if test -n "$GNU_CC"; then
+        AC_DEFINE(OS2)
+        AC_DEFINE(XP_OS2_EMX)
+        AC_DEFINE(OS2EMX_PLAIN_CHAR)
+        AC_DEFINE(TCPV40HDRS)
+        AR=emxomfar
+        AR_FLAGS='r $@'
+        CFLAGS="$CFLAGS -Zomf"
+        CXXFLAGS="$CXXFLAGS -Zomf"
+        DSO_LDOPTS='-Zdll'
+        BIN_FLAGS='-Zlinker /ST:0x100000'
+        IMPLIB='emximp -o'
+        FILTER='emxexp -o'
+        LDFLAGS='-Zmap'
+        WARNINGS_AS_ERRORS='-Werror'
+        MOZ_DEBUG_FLAGS="-g -fno-inline"
+        MOZ_OPTIMIZE_FLAGS="-O2"
+        MOZ_OPTIMIZE_LDFLAGS="-s -Zlinker /EXEPACK:2 -Zlinker /PACKCODE -Zlinker /PACKDATA"
+        MOZ_XPCOM_OBSOLETE_LIBS='-L$(LIBXUL_DIST)/lib $(LIBXUL_DIST)/lib/xpcomct.lib'
+        DYNAMIC_XPCOM_LIBS='-L$(LIBXUL_DIST)/lib $(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/xpcomcor.lib'
+        LIBXUL_LIBS='-L$(LIBXUL_DIST)/lib $(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/xul.lib'
+        if test -n "$MOZ_OS2_HIGH_MEMORY"; then
+          DSO_LDOPTS="$DSO_LDOPTS -Zhigh-mem"
+          LDFLAGS="$LDFLAGS -Zhigh-mem"
+          MOZ_OPTIMIZE_LDFLAGS="$MOZ_OPTIMIZE_LDFLAGS -Zhigh-mem"
+          AC_DEFINE(MOZ_OS2_HIGH_MEMORY)
+        fi
+
+        # GCC for OS/2 currently predefines these, but we don't want them
+        _DEFINES_CFLAGS="$_DEFINES_CFLAGS -Uunix -U__unix -U__unix__"
+        _DEFINES_CXXFLAGS="$_DEFINES_CXXFLAGS -Uunix -U__unix -U__unix__"
+
+        AC_CACHE_CHECK(for __declspec(dllexport),
+           ac_os2_declspec,
+           [AC_TRY_COMPILE([__declspec(dllexport) void ac_os2_declspec(void) {}],
+                           [return 0;],
+                           ac_os2_declspec="yes",
+                           ac_os2_declspec="no")])
+        if test "$ac_os2_declspec" = "yes"; then
+           FILTER='true'
+           MOZ_OS2_USE_DECLSPEC='1'
+        fi
+        
+    # Visual Age C++ build
+    elif test "$VACPP" = "yes"; then
+        MOZ_BUILD_ROOT=`pwd -D`
+        OBJ_SUFFIX=obj
+        AR=-ilib
+        AR_FLAGS='/NOL /NOI /O:$(subst /,\\,$@)'
+        AR_LIST='/L'
+        AR_EXTRACT='-*'
+        AR_DELETE='-'
+        AS=alp
+        ASFLAGS='-Mb'
+        AS_DASH_C_FLAG=''
+        ASM_SUFFIX=asm
+        LD='-ilink'
+        CFLAGS="/Q /qlibansi /Gm+ /Su4 /Mp /Tl9"
+        CXXFLAGS="/Q /qlibansi /Gm+ /Su4 /Mp /Tl9 /Gx+"
+        MOZ_DEBUG_FLAGS="/Ti+"
+        WARNINGS_AS_ERRORS='-WX'
+        MOZ_OPTIMIZE_FLAGS="/O+ /Gl+ /G5 /qarch=pentium"
+        LDFLAGS="/NOL /M"
+        MOZ_DEBUG_LDFLAGS="/DE"
+        MOZ_OPTIMIZE_LDFLAGS="/OPTFUNC /EXEPACK:2 /PACKCODE /PACKDATA"
+        DSO_LDOPTS=''
+        DSO_PIC_CFLAGS=
+        IMPLIB='implib /NOL /NOI'
+        FILTER='cppfilt -q -B -P'
+        AC_DEFINE(NO_ANSI_KEYWORDS)
+        AC_DEFINE(OS2,4)
+        AC_DEFINE(_X86_)
+        AC_DEFINE(XP_OS2_VACPP)
+        AC_DEFINE(TCPV40HDRS)
+        AC_DEFINE(NSCAP_DISABLE_DEBUG_PTR_TYPES)
+        AC_DEFINE(STDC_HEADERS)
+        MOZ_COMPONENT_NSPR_LIBS='$(NSPR_LIBS)'
+        MKSHLIB='$(LD) $(DSO_LDOPTS)'
+        MKCSHLIB='$(LD) $(DSO_LDOPTS)'
+        MOZ_JS_LIBS='$(LIBXUL_DIST)/lib/mozjs.lib'
+        MOZ_XPCOM_OBSOLETE_LIBS='$(LIBXUL_DIST)/lib/xpcomct.lib'
+        DYNAMIC_XPCOM_LIBS='$(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/xpcomcor.lib'
+        LIBXUL_LIBS='$(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/xul.lib'
+    fi
+    ;;
+
+alpha*-*-osf*)
+    if test "$GNU_CC"; then
+      MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-soname,$@ -o $@'
+      MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-soname,$@ -o $@'
+
+    else
+	MOZ_DEBUG_FLAGS='-g'
+	ASFLAGS='-I$(MOZILLA_SRCDIR)/xpcom/reflect/xptcall/public -g'
+	CFLAGS="$CFLAGS -ieee"
+	CXXFLAGS="$CXXFLAGS "'-noexceptions -ieee  -ptr $(DIST)/cxx_repository'
+	DSO_LDOPTS='-shared -msym -expect_unresolved \* -update_registry $(DIST)/so_locations'
+	DSO_CFLAGS=
+	DSO_PIC_CFLAGS=
+	MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -soname $@ -o $@'
+	MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -soname $@ -o $@'
+	MKSHLIB_FORCE_ALL='-all'
+	MKSHLIB_UNFORCE_ALL='-none'
+	dnl Might fix the libxpcom.so breakage on this platform as well....
+	AC_DEFINE(NSCAP_DISABLE_TEST_DONTQUERY_CASES)
+	AC_DEFINE(NSCAP_DISABLE_DEBUG_PTR_TYPES)
+    fi
+    if test -z "$GNU_CXX"; then
+      COMPAQ_CXX=1
+    fi
+    AC_DEFINE(NEED_USLEEP_PROTOTYPE)
+    ;;
+
+*-qnx*) 
+    DIRENT_INO=d_stat.st_ino
+    dnl Solves the problems the QNX compiler has with nsCOMPtr.h.
+    AC_DEFINE(NSCAP_DISABLE_TEST_DONTQUERY_CASES)
+    AC_DEFINE(NSCAP_DISABLE_DEBUG_PTR_TYPES)
+    dnl Explicit set STDC_HEADERS to workaround QNX 6.0's failing of std test
+    AC_DEFINE(STDC_HEADERS)
+    if test "$no_x" = "yes"; then
+	    _PLATFORM_DEFAULT_TOOLKIT='photon'
+	    TK_CFLAGS='-I/usr/nto/include/photon'
+	    TK_LIBS='-lphoton -lphrender'
+    fi
+    ;;
+
+*-sco*) 
+    AC_DEFINE(NSCAP_DISABLE_TEST_DONTQUERY_CASES)
+    AC_DEFINE(NSCAP_DISABLE_DEBUG_PTR_TYPES)
+    CXXFLAGS="$CXXFLAGS -I/usr/include/CC"
+    if test ! "$GNU_CC"; then
+       DSO_LDOPTS='-G'
+    fi
+    ;;
+
+dnl the qsort routine under solaris is faulty
+*-solaris*) 
+    AC_DEFINE(SOLARIS)
+    TARGET_NSPR_MDCPUCFG='\"md/_solaris.cfg\"'
+    SYSTEM_MAKEDEPEND=
+    # $ORIGIN/.. is for shared libraries under components/ to locate shared
+    # libraries one level up (e.g. libnspr4.so)
+    LDFLAGS="$LDFLAGS -z ignore -R '\$\$ORIGIN:\$\$ORIGIN/..'"
+    MOZ_MEMORY=1
+    if test -z "$GNU_CC"; then
+       NS_USE_NATIVE=1
+       MOZ_FIX_LINK_PATHS='-R $(LIBXUL_DIST)/bin'
+       AC_DEFINE(NSCAP_DISABLE_DEBUG_PTR_TYPES)
+
+       if test "$CPU_ARCH" != "sparc"; then
+          CFLAGS="$CFLAGS -xlibmieee -xstrconst -xbuiltin=%all"
+          CXXFLAGS="$CXXFLAGS -xlibmieee -xbuiltin=%all -features=tmplife -norunpath"
+       else
+          # Do not use -xbuiltin on SPARC to get around a bug of compiler
+          CFLAGS="$CFLAGS -xlibmieee -xstrconst -xbuiltin=%none"
+          CXXFLAGS="$CXXFLAGS -xlibmieee -xbuiltin=%none -features=tmplife -norunpath"
+       fi
+
+       LDFLAGS="-xildoff -z lazyload -z combreloc $LDFLAGS"
+       if test -z "$CROSS_COMPILE" && test -f /usr/lib/ld/map.noexstk; then
+           _SAVE_LDFLAGS=$LDFLAGS
+           LDFLAGS="-M /usr/lib/ld/map.noexstk $LDFLAGS" 
+           AC_TRY_LINK([#include <stdio.h>],
+                       [printf("Hello World\n");],
+                       ,
+                       [LDFLAGS=$_SAVE_LDFLAGS])
+       fi
+       WARNINGS_AS_ERRORS='-Werror'
+       MOZ_OPTIMIZE_FLAGS="-xO4"
+       MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_FLAGS) $(DSO_LDOPTS) -h $@ -o $@'
+       MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_FLAGS) -G -z muldefs -h $@ -o $@'
+       MKSHLIB_FORCE_ALL='-z allextract'
+       MKSHLIB_UNFORCE_ALL='-z defaultextract'
+       DSO_LDOPTS='-G -z muldefs'
+       AR_LIST="$AR t"
+       AR_EXTRACT="$AR x"
+       AR_DELETE="$AR d"
+       AR='$(CXX) -xar'
+       AR_FLAGS='-o $@'
+       AS='/usr/ccs/bin/as'
+       ASFLAGS="$ASFLAGS -K PIC -L -P -D_ASM -D__STDC__=0"
+       AS_DASH_C_FLAG=''
+       TARGET_COMPILER_ABI="sunc"
+        CC_VERSION=`$CC -V 2>&1 | grep '^cc:' 2>/dev/null | $AWK -F\: '{ print $2 }'`
+        CXX_VERSION=`$CXX -V 2>&1 | grep '^CC:' 2>/dev/null | $AWK -F\: '{ print $2 }'`
+       AC_MSG_CHECKING([for Forte compiler version >= WS6U2])
+       AC_LANG_SAVE
+       AC_LANG_CPLUSPLUS
+       AC_TRY_COMPILE([],
+           [#if (__SUNPRO_CC < 0x530)
+           #error "Denied"
+           #endif],
+           _BAD_COMPILER=,_BAD_COMPILER=1)
+        if test -n "$_BAD_COMPILER"; then
+            _res="no"
+            AC_MSG_ERROR([Forte version WS6U2 or higher is required to build. Your compiler version is $CC_VERSION .])
+        else
+            _res="yes"
+        fi
+        AC_MSG_RESULT([$_res])
+        AC_LANG_RESTORE
+    else
+       ASFLAGS="$ASFLAGS -fPIC"
+       DSO_LDOPTS='-G'
+       _WARNINGS_CFLAGS=''
+       _WARNINGS_CXXFLAGS=''
+       if test "$OS_RELEASE" = "5.3"; then
+	  AC_DEFINE(MUST_UNDEF_HAVE_BOOLEAN_AFTER_INCLUDES)
+       fi
+    fi
+    if test "$OS_RELEASE" = "5.5.1"; then
+       AC_DEFINE(NEED_USLEEP_PROTOTYPE)
+    fi
+    ;;
+
+*-sunos*) 
+    DSO_LDOPTS='-Bdynamic'
+    MKSHLIB='-$(LD) $(DSO_LDOPTS) -o $@'
+    MKCSHLIB='-$(LD) $(DSO_LDOPTS) -o $@'
+    AC_DEFINE(SUNOS4)
+    AC_DEFINE(SPRINTF_RETURNS_STRING)
+    case "$(target_os)" in
+    sunos4.1*)
+        DLL_SUFFIX='.so.1.0'
+        ;;
+    esac
+    ;;
+
+*-sysv4.2uw7*) 
+	NSPR_LIBS="-lnspr$NSPR_VERSION -lplc$NSPR_VERSION -lplds$NSPR_VERSION -L/usr/ccs/lib -lcrt"
+    ;;
+
+*-os2*)
+    HOST_NSPR_MDCPUCFG='\"md/_os2.cfg\"'
+    ;;
+
+esac
+
+dnl Only one oddball right now (QNX), but this gives us flexibility
+dnl if any other platforms need to override this in the future.
+AC_DEFINE_UNQUOTED(D_INO,$DIRENT_INO)
+
+dnl ========================================================
+dnl Any platform that doesn't have MKSHLIB_FORCE_ALL defined
+dnl by now will not have any way to link most binaries (tests
+dnl as well as viewer, apprunner, etc.), because some symbols
+dnl will be left out of the "composite" .so's by ld as unneeded.
+dnl So, by defining NO_LD_ARCHIVE_FLAGS for these platforms,
+dnl they can link in the static libs that provide the missing
+dnl symbols.
+dnl ========================================================
+NO_LD_ARCHIVE_FLAGS=
+if test -z "$MKSHLIB_FORCE_ALL" || test -z "$MKSHLIB_UNFORCE_ALL"; then
+    NO_LD_ARCHIVE_FLAGS=1
+fi
+case "$target" in
+*-os2*)
+    NO_LD_ARCHIVE_FLAGS=
+    ;;
+*-aix4.3*|*-aix5*)
+    NO_LD_ARCHIVE_FLAGS=
+    ;;
+*-openvms*)
+    NO_LD_ARCHIVE_FLAGS=
+    ;;
+*-msvc*|*-mks*|*-mingw*|*-cygwin*|*-wince)
+    if test -z "$GNU_CC"; then
+        NO_LD_ARCHIVE_FLAGS=
+    fi
+    ;;
+esac
+AC_SUBST(NO_LD_ARCHIVE_FLAGS)
+
+dnl
+dnl Indicate that platform requires special thread safe 
+dnl locking when starting up the OJI JVM 
+dnl (see mozilla/modules/oji/src/nsJVMManager.cpp)
+dnl ========================================================
+case "$target" in
+    *-hpux*)      
+        AC_DEFINE(MOZ_OJI_REQUIRE_THREAD_SAFE_ON_STARTUP)
+        ;;
+esac
+
+dnl ========================================================
+dnl = Flags to strip unused symbols from .so components
+dnl ========================================================
+case "$target" in
+    *-linux*|*-kfreebsd*-gnu)
+        MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-Wl,--version-script -Wl,$(BUILD_TOOLS)/gnu-ld-scripts/components-version-script'
+        ;;
+    *-solaris*)
+        if test -z "$GNU_CC"; then
+         MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-M $(BUILD_TOOLS)/gnu-ld-scripts/components-mapfile'
+        else
+         if test -z "$GCC_USE_GNU_LD"; then
+          MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-Wl,-M -Wl,$(BUILD_TOOLS)/gnu-ld-scripts/components-mapfile'
+         else
+          MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-Wl,--version-script -Wl,$(BUILD_TOOLS)/gnu-ld-scripts/components-version-script'
+         fi
+        fi
+        ;;
+    *-nto*) 
+        MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-Wl,--version-script,$(BUILD_TOOLS)/gnu-ld-scripts/components-version-script'
+        ;;
+    *-darwin*)
+        MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-Wl,-exported_symbols_list -Wl,$(BUILD_TOOLS)/gnu-ld-scripts/components-export-list'
+        ;;
+    *-cygwin*|*-mingw*|*-mks*|*-msvc|*-wince)
+        if test -n "$GNU_CC"; then
+           MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-Wl,--version-script,$(BUILD_TOOLS)/gnu-ld-scripts/components-version-script'
+        fi
+        ;;
+esac
+
+if test -z "$COMPILE_ENVIRONMENT"; then
+    SKIP_COMPILER_CHECKS=1
+    SKIP_LIBRARY_CHECKS=1
+fi
+
+if test -z "$SKIP_COMPILER_CHECKS"; then
+dnl Checks for typedefs, structures, and compiler characteristics.
+dnl ========================================================
+AC_LANG_C
+AC_HEADER_STDC
+AC_C_CONST
+AC_TYPE_MODE_T
+AC_TYPE_OFF_T
+AC_TYPE_PID_T
+AC_TYPE_SIZE_T
+AC_STRUCT_ST_BLKSIZE
+AC_MSG_CHECKING(for siginfo_t)
+AC_CACHE_VAL(ac_cv_siginfo_t,
+ [AC_TRY_COMPILE([#define _POSIX_C_SOURCE 199506L
+                  #include <signal.h>],
+                 [siginfo_t* info;],
+                 [ac_cv_siginfo_t=true],
+                 [ac_cv_siginfo_t=false])])
+if test "$ac_cv_siginfo_t" = true ; then
+  AC_DEFINE(HAVE_SIGINFO_T)
+  AC_MSG_RESULT(yes)
+else
+  AC_MSG_RESULT(no)
+fi
+
+dnl Visual Age for os/2 also defines size_t and off_t in certain 
+dnl  header files.  These defines make Visual Age use the mozilla
+dnl  defines types.
+if test "$VACPP" = "yes"; then
+   AC_DEFINE(__size_t)
+   AC_DEFINE(__off_t)
+fi
+
+dnl Check for int16_t, int32_t, int64_t, int64, uint, uint_t, and uint16_t.
+dnl ========================================================
+AC_MSG_CHECKING(for int16_t)
+AC_CACHE_VAL(ac_cv_int16_t,
+ [AC_TRY_COMPILE([#include <stdio.h>
+                  #include <sys/types.h>],
+                 [int16_t foo = 0;],
+                 [ac_cv_int16_t=true],
+                 [ac_cv_int16_t=false])])
+if test "$ac_cv_int16_t" = true ; then
+  AC_DEFINE(HAVE_INT16_T)
+  AC_MSG_RESULT(yes)
+else
+  AC_MSG_RESULT(no)
+fi
+AC_MSG_CHECKING(for int32_t)
+AC_CACHE_VAL(ac_cv_int32_t,
+ [AC_TRY_COMPILE([#include <stdio.h>
+                  #include <sys/types.h>],
+                 [int32_t foo = 0;],
+                 [ac_cv_int32_t=true],
+                 [ac_cv_int32_t=false])])
+if test "$ac_cv_int32_t" = true ; then
+  AC_DEFINE(HAVE_INT32_T)
+  AC_MSG_RESULT(yes)
+else
+  AC_MSG_RESULT(no)
+fi
+AC_MSG_CHECKING(for int64_t)
+AC_CACHE_VAL(ac_cv_int64_t,
+ [AC_TRY_COMPILE([#include <stdio.h>
+                  #include <sys/types.h>],
+                 [int64_t foo = 0;],
+                 [ac_cv_int64_t=true],
+                 [ac_cv_int64_t=false])])
+if test "$ac_cv_int64_t" = true ; then
+  AC_DEFINE(HAVE_INT64_T)
+  AC_MSG_RESULT(yes)
+else
+  AC_MSG_RESULT(no)
+fi
+AC_MSG_CHECKING(for int64)
+AC_CACHE_VAL(ac_cv_int64,
+ [AC_TRY_COMPILE([#include <stdio.h>
+                  #include <sys/types.h>],
+                 [int64 foo = 0;],
+                 [ac_cv_int64=true],
+                 [ac_cv_int64=false])])
+if test "$ac_cv_int64" = true ; then
+  AC_DEFINE(HAVE_INT64)
+  AC_MSG_RESULT(yes)
+else
+  AC_MSG_RESULT(no)
+fi
+AC_MSG_CHECKING(for uint)
+AC_CACHE_VAL(ac_cv_uint,
+ [AC_TRY_COMPILE([#include <stdio.h>
+                  #include <sys/types.h>],
+                 [uint foo = 0;],
+                 [ac_cv_uint=true],
+                 [ac_cv_uint=false])])
+if test "$ac_cv_uint" = true ; then
+  AC_DEFINE(HAVE_UINT)
+  AC_MSG_RESULT(yes)
+else
+  AC_MSG_RESULT(no)
+fi
+AC_MSG_CHECKING(for uint_t)
+AC_CACHE_VAL(ac_cv_uint_t,
+ [AC_TRY_COMPILE([#include <stdio.h>
+                  #include <sys/types.h>],
+                 [uint_t foo = 0;],
+                 [ac_cv_uint_t=true],
+                 [ac_cv_uint_t=false])])
+if test "$ac_cv_uint_t" = true ; then
+  AC_DEFINE(HAVE_UINT_T)
+  AC_MSG_RESULT(yes)
+else
+  AC_MSG_RESULT(no)
+fi
+AC_MSG_CHECKING(for uint16_t)
+AC_CACHE_VAL(ac_cv_uint16_t,
+ [AC_TRY_COMPILE([#include <stdio.h>
+                  #include <sys/types.h>],
+                 [uint16_t foo = 0;],
+                 [ac_cv_uint16_t=true],
+                 [ac_cv_uint16_t=false])])
+if test "$ac_cv_uint16_t" = true ; then
+  AC_DEFINE(HAVE_UINT16_T)
+  AC_MSG_RESULT(yes)
+else
+  AC_MSG_RESULT(no)
+fi
+
+dnl On the gcc trunk (as of 2001-02-09) _GNU_SOURCE, and thus __USE_GNU,
+dnl are defined when compiling C++ but not C.  Since the result of this
+dnl test is used only in C++, do it in C++.
+AC_LANG_CPLUSPLUS
+
+AC_MSG_CHECKING(for uname.domainname)
+AC_CACHE_VAL(ac_cv_have_uname_domainname_field,
+    [AC_TRY_COMPILE([#include <sys/utsname.h>],
+        [ struct utsname *res; char *domain; 
+            (void)uname(res);  if (res != 0) { domain = res->domainname; } ],
+        [ac_cv_have_uname_domainname_field=true],
+        [ac_cv_have_uname_domainname_field=false])])
+
+if test "$ac_cv_have_uname_domainname_field" = "true"; then
+    AC_DEFINE(HAVE_UNAME_DOMAINNAME_FIELD)
+    AC_MSG_RESULT(yes)
+else
+    AC_MSG_RESULT(no)
+fi
+
+AC_MSG_CHECKING(for uname.__domainname)
+AC_CACHE_VAL(ac_cv_have_uname_us_domainname_field,
+    [AC_TRY_COMPILE([#include <sys/utsname.h>],
+        [ struct utsname *res; char *domain; 
+            (void)uname(res);  if (res != 0) { domain = res->__domainname; } ],
+        [ac_cv_have_uname_us_domainname_field=true],
+        [ac_cv_have_uname_us_domainname_field=false])])
+
+if test "$ac_cv_have_uname_us_domainname_field" = "true"; then
+    AC_DEFINE(HAVE_UNAME_US_DOMAINNAME_FIELD)
+    AC_MSG_RESULT(yes)
+else
+    AC_MSG_RESULT(no)
+fi
+
+AC_LANG_C
+
+dnl Check for usable wchar_t (2 bytes, unsigned)
+dnl (we really don't need the unsignedness check anymore)
+dnl ========================================================
+
+AC_CACHE_CHECK(for usable wchar_t (2 bytes, unsigned),
+    ac_cv_have_usable_wchar_v2,
+    [AC_TRY_COMPILE([#include <stddef.h>
+                     $configure_static_assert_macros],
+                    [CONFIGURE_STATIC_ASSERT(sizeof(wchar_t) == 2);
+                     CONFIGURE_STATIC_ASSERT((wchar_t)-1 > (wchar_t) 0)],
+                    ac_cv_have_usable_wchar_v2="yes",
+                    ac_cv_have_usable_wchar_v2="no")])
+if test "$ac_cv_have_usable_wchar_v2" = "yes"; then
+    AC_DEFINE(HAVE_CPP_2BYTE_WCHAR_T)
+    HAVE_CPP_2BYTE_WCHAR_T=1
+else
+dnl This is really gcc-only
+dnl Do this test using CXX only since some versions of gcc
+dnl 2.95-2.97 have a signed wchar_t in c++ only and some versions
+dnl only have short-wchar support for c++.
+dnl Note that we assume that mac & win32 have short wchar (see nscore.h)
+
+    AC_LANG_SAVE
+    AC_LANG_CPLUSPLUS
+    _SAVE_CXXFLAGS=$CXXFLAGS
+    CXXFLAGS="$CXXFLAGS -fshort-wchar"
+
+    AC_CACHE_CHECK(for compiler -fshort-wchar option, 
+        ac_cv_have_usable_wchar_option_v2,
+        [AC_TRY_LINK([#include <stddef.h>
+                      $configure_static_assert_macros],
+                     [CONFIGURE_STATIC_ASSERT(sizeof(wchar_t) == 2);
+                      CONFIGURE_STATIC_ASSERT((wchar_t)-1 > (wchar_t) 0)],
+                     ac_cv_have_usable_wchar_option_v2="yes",
+                     ac_cv_have_usable_wchar_option_v2="no")])
+
+    if test "$ac_cv_have_usable_wchar_option_v2" = "yes"; then
+        AC_DEFINE(HAVE_CPP_2BYTE_WCHAR_T)
+        HAVE_CPP_2BYTE_WCHAR_T=1
+    else    
+        CXXFLAGS=$_SAVE_CXXFLAGS
+    fi
+    AC_LANG_RESTORE
+fi
+
+dnl Check for .hidden assembler directive and visibility attribute.
+dnl Borrowed from glibc configure.in
+dnl ===============================================================
+if test "$GNU_CC"; then
+  AC_CACHE_CHECK(for visibility(hidden) attribute,
+                 ac_cv_visibility_hidden,
+                 [cat > conftest.c <<EOF
+                  int foo __attribute__ ((visibility ("hidden"))) = 1;
+EOF
+                  ac_cv_visibility_hidden=no
+                  if ${CC-cc} -Werror -S conftest.c -o conftest.s >/dev/null 2>&1; then
+                    if egrep '\.(hidden|private_extern).*foo' conftest.s >/dev/null; then
+                      ac_cv_visibility_hidden=yes
+                    fi
+                  fi
+                  rm -f conftest.[cs]
+                 ])
+  if test "$ac_cv_visibility_hidden" = "yes"; then
+    AC_DEFINE(HAVE_VISIBILITY_HIDDEN_ATTRIBUTE)
+
+    AC_CACHE_CHECK(for visibility(default) attribute,
+                   ac_cv_visibility_default,
+                   [cat > conftest.c <<EOF
+                    int foo __attribute__ ((visibility ("default"))) = 1;
+EOF
+                    ac_cv_visibility_default=no
+                    if ${CC-cc} -fvisibility=hidden -Werror -S conftest.c -o conftest.s >/dev/null 2>&1; then
+                      if ! egrep '\.(hidden|private_extern).*foo' conftest.s >/dev/null; then
+                        ac_cv_visibility_default=yes
+                      fi
+                    fi
+                    rm -f conftest.[cs]
+                   ])
+    if test "$ac_cv_visibility_default" = "yes"; then
+      AC_DEFINE(HAVE_VISIBILITY_ATTRIBUTE)
+
+      AC_CACHE_CHECK(for visibility pragma support,
+                     ac_cv_visibility_pragma,
+                     [cat > conftest.c <<EOF
+#pragma GCC visibility push(hidden)
+                      int foo_hidden = 1;
+#pragma GCC visibility push(default)
+                      int foo_default = 1;
+EOF
+                      ac_cv_visibility_pragma=no
+                      if ${CC-cc} -Werror -S conftest.c -o conftest.s >/dev/null 2>&1; then
+                        if egrep '\.(hidden|private_extern).*foo_hidden' conftest.s >/dev/null; then
+                          if ! egrep '\.(hidden|private_extern).*foo_default' conftest.s > /dev/null; then
+                            ac_cv_visibility_pragma=yes
+                          fi
+                        fi
+                      fi
+                      rm -f conftest.[cs]
+                    ])
+      if test "$ac_cv_visibility_pragma" = "yes"; then
+        AC_CACHE_CHECK(For gcc visibility bug with class-level attributes (GCC bug 26905),
+                       ac_cv_have_visibility_class_bug,
+                       [cat > conftest.c <<EOF
+#pragma GCC visibility push(hidden)
+struct __attribute__ ((visibility ("default"))) TestStruct {
+  static void Init();
+};
+__attribute__ ((visibility ("default"))) void TestFunc() {
+  TestStruct::Init();
+}
+EOF
+                       ac_cv_have_visibility_class_bug=no
+                       if ! ${CXX-g++} ${CXXFLAGS} ${DSO_PIC_CFLAGS} ${DSO_LDOPTS} -S -o conftest.S conftest.c > /dev/null 2>&1 ; then
+                         ac_cv_have_visibility_class_bug=yes
+                       else
+                         if test `egrep -c '@PLT|\\$stub' conftest.S` = 0; then
+                           ac_cv_have_visibility_class_bug=yes
+                         fi
+                       fi
+                       rm -rf conftest.{c,S}
+                       ])
+
+        AC_CACHE_CHECK(For x86_64 gcc visibility bug with builtins (GCC bug 20297),
+                       ac_cv_have_visibility_builtin_bug,
+                       [cat > conftest.c <<EOF
+#pragma GCC visibility push(hidden)
+#pragma GCC visibility push(default)
+#include <string.h>
+#pragma GCC visibility pop
+
+__attribute__ ((visibility ("default"))) void Func() {
+  char c[[100]];
+  memset(c, 0, sizeof(c));
+}
+EOF
+                       ac_cv_have_visibility_builtin_bug=no
+                       if ! ${CC-cc} ${CFLAGS} ${DSO_PIC_CFLAGS} ${DSO_LDOPTS} -O2 -S -o conftest.S conftest.c > /dev/null 2>&1 ; then
+                         ac_cv_have_visibility_builtin_bug=yes
+                       else
+                         if test `grep -c "@PLT" conftest.S` = 0; then
+                           ac_cv_visibility_builtin_bug=yes
+                         fi
+                       fi
+                       rm -f conftest.{c,S}
+                       ])
+        if test "$ac_cv_have_visibility_builtin_bug" = "no" -a \
+                "$ac_cv_have_visibility_class_bug" = "no"; then
+          VISIBILITY_FLAGS='-I$(DIST)/include/system_wrappers -include $(MOZILLA_SRCDIR)/config/gcc_hidden.h'
+          WRAP_SYSTEM_INCLUDES=1
+        else
+          VISIBILITY_FLAGS='-fvisibility=hidden'
+        fi # have visibility pragma bug
+      fi   # have visibility pragma
+    fi     # have visibility(default) attribute
+  fi       # have visibility(hidden) attribute
+fi         # GNU_CC
+
+AC_SUBST(WRAP_SYSTEM_INCLUDES)
+AC_SUBST(VISIBILITY_FLAGS)
+
+dnl Checks for header files.
+dnl ========================================================
+AC_HEADER_DIRENT
+case "$target_os" in
+freebsd*)
+# for stuff like -lXshm
+    CPPFLAGS="${CPPFLAGS} ${X_CFLAGS}"
+    ;;
+esac
+AC_CHECK_HEADERS(sys/byteorder.h compat.h getopt.h)
+AC_CHECK_HEADERS(sys/bitypes.h memory.h unistd.h)
+AC_CHECK_HEADERS(gnu/libc-version.h nl_types.h)
+AC_CHECK_HEADERS(malloc.h)
+AC_CHECK_HEADERS(X11/XKBlib.h)
+
+dnl These are all the places some variant of statfs can be hiding.
+AC_CHECK_HEADERS(sys/statvfs.h sys/statfs.h sys/vfs.h sys/mount.h)
+
+dnl Try for MMX support
+dnl NB - later gcc versions require -mmmx for this header to be successfully
+dnl included (or another option which implies it, such as -march=pentium-mmx)
+AC_CHECK_HEADERS(mmintrin.h)
+
+dnl Check whether the compiler supports the new-style C++ standard
+dnl library headers (i.e. <new>) or needs the old "new.h"
+AC_LANG_CPLUSPLUS
+NEW_H=new.h
+AC_CHECK_HEADER(new, [NEW_H=new])
+AC_DEFINE_UNQUOTED(NEW_H, <$NEW_H>)
+AC_LANG_C
+
+AC_ARG_ENABLE(dtrace,
+              [  --enable-dtrace         build with dtrace support if available (default=no)],
+              [enable_dtrace="yes"],)
+if test "x$enable_dtrace" = "xyes"; then
+  AC_CHECK_HEADER(sys/sdt.h, HAVE_DTRACE=1)
+  if test -n "$HAVE_DTRACE"; then
+      AC_DEFINE(INCLUDE_MOZILLA_DTRACE)
+  else
+      AC_MSG_ERROR([dtrace enabled but sys/sdt.h not found]);
+  fi
+fi
+AC_SUBST(HAVE_DTRACE)
+
+case $target in
+*-aix4.3*|*-aix5*)
+	;;
+*)
+	AC_CHECK_HEADERS(sys/cdefs.h)
+	;;
+esac
+
+dnl Checks for libraries.
+dnl ========================================================
+case $target in
+*-hpux11.*)
+	;;
+*)
+	AC_CHECK_LIB(c_r, gethostbyname_r)
+	;;
+esac
+
+dnl We don't want to link with libdl even if it's present on OS X, since
+dnl it's not used and not part of the default installation.
+dnl The same goes for BeOS.
+dnl We don't want to link against libm or libpthread on Darwin since
+dnl they both are just symlinks to libSystem and explicitly linking
+dnl against libSystem causes issues when debugging (see bug 299601).
+case $target in
+*-darwin*)
+    ;;
+*-beos*)
+    ;;
+*)
+    AC_CHECK_LIB(m, atan)
+    AC_CHECK_LIB(dl, dlopen,
+    AC_CHECK_HEADER(dlfcn.h, 
+        LIBS="-ldl $LIBS"
+        AC_DEFINE(HAVE_LIBDL)))
+    ;;
+esac
+
+_SAVE_CFLAGS="$CFLAGS"
+CFLAGS="$CFLAGS -D_GNU_SOURCE"
+AC_CHECK_FUNCS(dladdr)
+CFLAGS="$_SAVE_CFLAGS"
+
+if test ! "$GNU_CXX"; then
+
+    case $target in
+    *-aix*)
+	AC_CHECK_LIB(C_r, demangle)
+	;;
+     *)
+	AC_CHECK_LIB(C, demangle)
+	;;
+     esac
+fi
+AC_CHECK_LIB(socket, socket)
+
+XLDFLAGS="$X_LIBS"
+XLIBS="$X_EXTRA_LIBS"
+
+dnl ========================================================
+dnl Checks for X libraries.
+dnl Ordering is important.
+dnl Xt is dependent upon SM as of X11R6
+dnl ========================================================
+if test "$no_x" = "yes"; then
+    AC_DEFINE(NO_X11)
+else
+    AC_DEFINE_UNQUOTED(FUNCPROTO,15)
+	XLIBS="-lX11 $XLIBS"
+	_SAVE_LDFLAGS="$LDFLAGS"
+	LDFLAGS="$XLDFLAGS $LDFLAGS"
+	AC_CHECK_LIB(X11, XDrawLines, [X11_LIBS="-lX11"],
+		[MISSING_X="$MISSING_X -lX11"], $XLIBS)
+	AC_CHECK_LIB(Xext, XextAddDisplay, [XEXT_LIBS="-lXext"],
+		[MISSING_X="$MISSING_X -lXext"], $XLIBS)
+   
+     
+	AC_CHECK_LIB(Xt, XtFree, [ XT_LIBS="-lXt"], [
+        unset ac_cv_lib_Xt_XtFree
+	    AC_CHECK_LIB(ICE, IceFlush, [XT_LIBS="-lICE $XT_LIBS"],, $XT_LIBS $XLIBS)
+	    AC_CHECK_LIB(SM, SmcCloseConnection, [XT_LIBS="-lSM $XT_LIBS"],, $XT_LIBS $XLIBS) 
+        AC_CHECK_LIB(Xt, XtFree, [ XT_LIBS="-lXt $XT_LIBS"],
+		    [MISSING_X="$MISSING_X -lXt"], $X_PRE_LIBS $XT_LIBS $XLIBS)
+        ])
+
+    # AIX needs the motif library linked before libXt to prevent
+    # crashes in plugins linked against Motif - Bug #98892
+    case "${target_os}" in
+    aix*)
+        XT_LIBS="-lXm $XT_LIBS"
+        ;;
+    esac
+
+    dnl ========================================================
+    dnl = Check for XShm
+    dnl ========================================================
+    AC_CHECK_LIB(Xext, XShmCreateImage, _HAVE_XSHM_XEXT=1,,
+        $XLIBS $XEXT_LIBS)
+    AC_CHECK_HEADER(X11/extensions/XShm.h)
+    if test "$ac_cv_header_X11_extensions_XShm_h" = "yes" &&
+        test -n "$_HAVE_XSHM_XEXT"; then
+        AC_DEFINE(HAVE_XSHM)
+    fi
+
+    dnl ========================================================
+    dnl = Check for XIE
+    dnl ========================================================
+    AC_CHECK_LIB(XIE, XieFloGeometry, [MOZ_XIE_LIBS="-lXIE"],,
+        $XLIBS $XEXT_LIBS)
+    AC_CHECK_HEADER(X11/extensions/XIElib.h)
+
+    if test "$MOZ_XIE_LIBS"; then
+	dnl ====================================================
+	dnl = If XIE is present and is desired, turn it on
+	dnl ====================================================
+	case $target in
+	    *-hpux*)
+		;;
+	    *)
+		HAVE_XIE=1
+		;;
+	esac
+    fi
+
+	LDFLAGS="$_SAVE_LDFLAGS"
+
+    dnl ========================================================
+    dnl = Check for freetype2 and its functionality
+    dnl ========================================================
+    AC_CHECK_FT2(6.1.0, [_HAVE_FREETYPE2=1], [_HAVE_FREETYPE2=])
+
+    if test "$_HAVE_FREETYPE2"; then
+    	_SAVE_LIBS="$LIBS"
+    	_SAVE_CFLAGS="$CFLAGS"
+    	LIBS="$LIBS $FT2_LIBS"
+    	CFLAGS="$CFLAGS $FT2_CFLAGS"
+
+        AC_CACHE_CHECK(for FT_Bitmap_Size.y_ppem,
+            ac_cv_member_FT_Bitmap_Size_y_ppem,
+            [AC_TRY_COMPILE([#include <ft2build.h>
+                             #include FT_FREETYPE_H],
+                            [FT_Bitmap_Size s;
+                             if (sizeof s.y_ppem) return 0;
+                             return 1],
+                            ac_cv_member_FT_Bitmap_Size_y_ppem=yes,
+                            ac_cv_member_FT_Bitmap_Size_y_ppem=no)])
+        if test "$ac_cv_member_FT_Bitmap_Size_y_ppem" = yes; then
+            HAVE_FT_BITMAP_SIZE_Y_PPEM=1
+        else
+            HAVE_FT_BITMAP_SIZE_Y_PPEM=0
+        fi
+        AC_DEFINE_UNQUOTED(HAVE_FT_BITMAP_SIZE_Y_PPEM,
+                           $HAVE_FT_BITMAP_SIZE_Y_PPEM,
+                           [FT_Bitmap_Size structure includes y_ppem field])
+
+        AC_CHECK_FUNCS(FT_GlyphSlot_Embolden FT_Load_Sfnt_Table FT_Select_Size)
+
+    	LIBS="$_SAVE_LIBS"
+    	CFLAGS="$_SAVE_CFLAGS"
+    fi
+
+fi # $no_x
+
+AC_SUBST(XCFLAGS)
+AC_SUBST(XLDFLAGS)
+AC_SUBST(XLIBS)
+AC_SUBST(XT_LIBS)
+
+dnl ========================================================
+dnl = pthread support
+dnl = Start by checking whether the system support pthreads
+dnl ========================================================
+case "$target_os" in
+darwin*)
+    USE_PTHREADS=1
+    ;;
+*)
+    MOZ_CHECK_PTHREADS(pthreads,
+        USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthreads",
+        MOZ_CHECK_PTHREADS(pthread,
+            USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthread",
+            MOZ_CHECK_PTHREADS(c_r,
+                USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lc_r",
+                MOZ_CHECK_PTHREADS(c,
+                    USE_PTHREADS=1
+                )
+            )
+        )
+    )
+    ;;
+esac
+
+dnl ========================================================
+dnl Check the command line for --with-pthreads 
+dnl ========================================================
+MOZ_ARG_WITH_BOOL(pthreads,
+[  --with-pthreads         Force use of system pthread library with NSPR ],
+[ if test "$USE_PTHREADS"x = x; then
+    AC_MSG_ERROR([ --with-pthreads specified for a system without pthread support ]);
+fi],
+    USE_PTHREADS=
+    _PTHREAD_LDFLAGS=
+)
+
+dnl ========================================================
+dnl Do the platform specific pthread hackery
+dnl ========================================================
+if test "$USE_PTHREADS"x != x
+then
+	dnl
+	dnl See if -pthread is supported.
+	dnl
+	rm -f conftest*
+	ac_cv_have_dash_pthread=no
+	AC_MSG_CHECKING(whether ${CC-cc} accepts -pthread)
+	echo 'int main() { return 0; }' | cat > conftest.c
+	${CC-cc} -pthread -o conftest conftest.c > conftest.out 2>&1
+	if test $? -eq 0; then
+		if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthread`" && test -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
+			ac_cv_have_dash_pthread=yes
+	        case "$target_os" in
+	        freebsd*)
+# Freebsd doesn't use -pthread for compiles, it uses them for linking
+                ;;
+	        *)
+			    CFLAGS="$CFLAGS -pthread"
+			    CXXFLAGS="$CXXFLAGS -pthread"
+                ;;
+	        esac
+		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
+	    *-*-freebsd*)
+			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"
+			else
+				_PTHREAD_LDFLAGS="-lc_r"
+			fi
+			;;
+
+	    *-*-openbsd*|*-*-bsdi*)
+			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"
+			fi
+			;;
+
+	    *-*-linux*|*-*-kfreebsd*-gnu)
+			AC_DEFINE(_REENTRANT) 
+			;;
+
+	    *-*-nto*) 
+			AC_DEFINE(_REENTRANT) 
+			;;
+
+	    *-aix4.3*|*-aix5*)
+			AC_DEFINE(_REENTRANT) 
+			;;
+
+	    *-hpux11.*)
+			AC_DEFINE(_REENTRANT) 
+			;;
+
+	    alpha*-*-osf*)
+			AC_DEFINE(_REENTRANT)
+			;;
+
+	    *-*-solaris*) 
+    			AC_DEFINE(_REENTRANT) 
+			if test ! "$GNU_CC"; then
+				CFLAGS="$CFLAGS -mt" 
+				CXXFLAGS="$CXXFLAGS -mt" 
+			fi
+			;;
+	esac
+    LDFLAGS="${_PTHREAD_LDFLAGS} ${LDFLAGS}"
+fi
+
+dnl ========================================================
+dnl See if mmap sees writes
+dnl For cross compiling, just define it as no, which is a safe default
+dnl ========================================================
+AC_MSG_CHECKING(whether mmap() sees write()s)
+
+changequote(,)
+mmap_test_prog='
+    #include <stdlib.h>
+    #include <unistd.h>
+    #include <sys/mman.h>
+    #include <sys/types.h>
+    #include <sys/stat.h>
+    #include <fcntl.h>
+
+    char fname[] = "conftest.file";
+    char zbuff[1024]; /* Fractional page is probably worst case */
+
+    int main() {
+	char *map;
+	int fd;
+	int i;
+	unlink(fname);
+	fd = open(fname, O_RDWR | O_CREAT, 0660);
+	if(fd<0) return 1;
+	unlink(fname);
+	write(fd, zbuff, sizeof(zbuff));
+	lseek(fd, 0, SEEK_SET);
+	map = (char*)mmap(0, sizeof(zbuff), PROT_READ, MAP_SHARED, fd, 0);
+	if(map==(char*)-1) return 2;
+	for(i=0; fname[i]; i++) {
+	    int rc = write(fd, &fname[i], 1);
+	    if(map[i]!=fname[i]) return 4;
+	}
+	return 0;
+    }
+'
+changequote([,])
+
+AC_TRY_RUN($mmap_test_prog , result="yes", result="no", result="yes")
+
+AC_MSG_RESULT("$result")
+
+if test "$result" = "no"; then
+    AC_DEFINE(MMAP_MISSES_WRITES)
+fi
+
+
+dnl Checks for library functions.
+dnl ========================================================
+AC_PROG_GCC_TRADITIONAL
+AC_FUNC_MEMCMP
+AC_CHECK_FUNCS(random strerror lchown fchmod snprintf statvfs memmove rint stat64 lstat64 truncate64 statvfs64)
+AC_CHECK_FUNCS(flockfile getpagesize)
+
+dnl localtime_r and strtok_r are only present on MacOS version 10.2 and higher
+if test -z "$MACOS_DEPLOYMENT_TARGET" || test "$MACOS_DEPLOYMENT_TARGET" -ge "100200"; then
+  AC_CHECK_FUNCS(localtime_r strtok_r)
+fi
+
+dnl check for wcrtomb/mbrtowc
+dnl =======================================================================
+if test -z "$MACOS_DEPLOYMENT_TARGET" || test "$MACOS_DEPLOYMENT_TARGET" -ge "100300"; then
+AC_LANG_SAVE
+AC_LANG_CPLUSPLUS
+AC_CACHE_CHECK(for wcrtomb,
+    ac_cv_have_wcrtomb,
+    [AC_TRY_LINK([#include <wchar.h>],
+                 [mbstate_t ps={0};wcrtomb(0,'f',&ps);],
+                 ac_cv_have_wcrtomb="yes",
+                 ac_cv_have_wcrtomb="no")])
+if test "$ac_cv_have_wcrtomb" = "yes"; then
+    AC_DEFINE(HAVE_WCRTOMB)
+fi
+AC_CACHE_CHECK(for mbrtowc,
+    ac_cv_have_mbrtowc,
+    [AC_TRY_LINK([#include <wchar.h>],
+                 [mbstate_t ps={0};mbrtowc(0,0,0,&ps);],
+                 ac_cv_have_mbrtowc="yes",
+                 ac_cv_have_mbrtowc="no")])
+if test "$ac_cv_have_mbrtowc" = "yes"; then
+    AC_DEFINE(HAVE_MBRTOWC)
+fi
+AC_LANG_RESTORE
+fi
+
+AC_CACHE_CHECK(
+    [for res_ninit()],
+    ac_cv_func_res_ninit,
+    [AC_TRY_LINK([
+        #ifdef linux
+        #define _BSD_SOURCE 1
+        #endif
+        #include <resolv.h>
+        ],
+        [int foo = res_ninit(&_res);],
+        [ac_cv_func_res_ninit=yes],
+        [ac_cv_func_res_ninit=no])
+    ])
+
+if test "$ac_cv_func_res_ninit" = "yes"; then
+    AC_DEFINE(HAVE_RES_NINIT)
+dnl must add the link line we do something as foolish as this... dougt
+dnl else
+dnl    AC_CHECK_LIB(bind, res_ninit, AC_DEFINE(HAVE_RES_NINIT),
+dnl        AC_CHECK_LIB(resolv, res_ninit, AC_DEFINE(HAVE_RES_NINIT)))
+fi
+
+AC_LANG_CPLUSPLUS
+AC_CACHE_CHECK(
+    [for gnu_get_libc_version()],
+    ac_cv_func_gnu_get_libc_version,
+    [AC_TRY_LINK([
+        #ifdef HAVE_GNU_LIBC_VERSION_H
+        #include <gnu/libc-version.h>
+        #endif
+        ],
+        [const char *glibc_version = gnu_get_libc_version();],
+        [ac_cv_func_gnu_get_libc_version=yes],
+        [ac_cv_func_gnu_get_libc_version=no] 
+        )]
+    )
+
+if test "$ac_cv_func_gnu_get_libc_version" = "yes"; then
+    AC_DEFINE(HAVE_GNU_GET_LIBC_VERSION)
+fi
+
+case $target_os in
+    os2*|msvc*|mks*|cygwin*|mingw*|darwin*|wince*|beos*)
+        ;;
+    *)
+    
+AC_CHECK_LIB(c, iconv, [_ICONV_LIBS="$_ICONV_LIBS"],
+    AC_CHECK_LIB(iconv, iconv, [_ICONV_LIBS="$_ICONV_LIBS -liconv"],
+        AC_CHECK_LIB(iconv, libiconv, [_ICONV_LIBS="$_ICONV_LIBS -liconv"])))
+_SAVE_LIBS=$LIBS
+LIBS="$LIBS $_ICONV_LIBS"
+AC_CACHE_CHECK(
+    [for iconv()],
+    ac_cv_func_iconv,
+    [AC_TRY_LINK([
+        #include <stdlib.h>
+        #include <iconv.h>
+        ],
+        [
+            iconv_t h = iconv_open("", "");
+            iconv(h, NULL, NULL, NULL, NULL);
+            iconv_close(h);
+        ],
+        [ac_cv_func_iconv=yes],
+        [ac_cv_func_iconv=no] 
+        )]
+    )
+if test "$ac_cv_func_iconv" = "yes"; then
+    AC_DEFINE(HAVE_ICONV)
+    DYNAMIC_XPCOM_LIBS="$DYNAMIC_XPCOM_LIBS $_ICONV_LIBS"
+    LIBXUL_LIBS="$LIBXUL_LIBS $_ICONV_LIBS"
+    LIBICONV="$_ICONV_LIBS"
+    AC_CACHE_CHECK(
+        [for iconv() with const input],
+        ac_cv_func_const_iconv,
+        [AC_TRY_COMPILE([
+            #include <stdlib.h>
+            #include <iconv.h>
+            ],
+            [
+                const char *input = "testing";
+                iconv_t h = iconv_open("", "");
+                iconv(h, &input, NULL, NULL, NULL);
+                iconv_close(h);
+            ],
+            [ac_cv_func_const_iconv=yes],
+            [ac_cv_func_const_iconv=no] 
+            )]
+        )
+    if test "$ac_cv_func_const_iconv" = "yes"; then
+        AC_DEFINE(HAVE_ICONV_WITH_CONST_INPUT)
+    fi
+fi
+LIBS=$_SAVE_LIBS
+
+    ;;
+esac
+
+AM_LANGINFO_CODESET
+
+AC_LANG_C
+
+dnl **********************
+dnl *** va_copy checks ***
+dnl **********************
+dnl we currently check for all three va_copy possibilities, so we get
+dnl all results in config.log for bug reports.
+AC_MSG_CHECKING(for an implementation of va_copy())
+AC_CACHE_VAL(ac_cv_va_copy,[
+    AC_TRY_RUN([
+        #include <stdarg.h>
+        void f (int i, ...) {
+            va_list args1, args2;
+            va_start (args1, i);
+            va_copy (args2, args1);
+            if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
+                exit (1);
+            va_end (args1); va_end (args2);
+        }
+        int main() { f (0, 42); return 0; }],
+        ac_cv_va_copy=yes,
+        ac_cv_va_copy=no,
+        ac_cv_va_copy=no
+    )
+])
+AC_MSG_RESULT($ac_cv_va_copy)
+AC_MSG_CHECKING(for an implementation of __va_copy())
+AC_CACHE_VAL(ac_cv___va_copy,[
+    AC_TRY_RUN([
+        #include <stdarg.h>
+        void f (int i, ...) {
+            va_list args1, args2;
+            va_start (args1, i);
+            __va_copy (args2, args1);
+            if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
+                exit (1);
+            va_end (args1); va_end (args2);
+        }
+        int main() { f (0, 42); return 0; }],
+        ac_cv___va_copy=yes,
+        ac_cv___va_copy=no,
+        ac_cv___va_copy=no
+    )
+])
+AC_MSG_RESULT($ac_cv___va_copy)
+AC_MSG_CHECKING(whether va_lists can be copied by value)
+AC_CACHE_VAL(ac_cv_va_val_copy,[
+    AC_TRY_RUN([
+        #include <stdarg.h>
+        void f (int i, ...) {
+            va_list args1, args2;
+            va_start (args1, i);
+            args2 = args1;
+            if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
+                exit (1);
+            va_end (args1); va_end (args2);
+        }
+        int main() { f (0, 42); return 0; }],
+        ac_cv_va_val_copy=yes,
+        ac_cv_va_val_copy=no,
+        ac_cv_va_val_copy=yes
+    )
+])
+if test "x$ac_cv_va_copy" = "xyes"; then
+    AC_DEFINE(VA_COPY, va_copy)
+    AC_DEFINE(HAVE_VA_COPY)
+elif test "x$ac_cv___va_copy" = "xyes"; then
+    AC_DEFINE(VA_COPY, __va_copy)
+    AC_DEFINE(HAVE_VA_COPY)
+fi
+
+if test "x$ac_cv_va_val_copy" = "xno"; then
+   AC_DEFINE(HAVE_VA_LIST_AS_ARRAY)
+fi
+AC_MSG_RESULT($ac_cv_va_val_copy)
+
+dnl Check for dll-challenged libc's.
+dnl This check is apparently only needed for Linux.
+case "$target" in
+	*-linux*)
+	    dnl ===================================================================
+	    _curdir=`pwd`
+	    export _curdir
+	    rm -rf conftest* _conftest
+	    mkdir _conftest
+	    cat >> conftest.C <<\EOF
+#include <stdio.h>
+#include <link.h>
+#include <dlfcn.h>
+#ifdef _dl_loaded
+void __dump_link_map(void) {
+  struct link_map *map = _dl_loaded;
+  while (NULL != map) {printf("0x%08x %s\n", map->l_addr, map->l_name); map = map->l_next;}
+}
+int main() {
+  dlopen("./conftest1.so",RTLD_LAZY);
+  dlopen("./../_conftest/conftest1.so",RTLD_LAZY);
+  dlopen("CURDIR/_conftest/conftest1.so",RTLD_LAZY);
+  dlopen("CURDIR/_conftest/../_conftest/conftest1.so",RTLD_LAZY);
+  __dump_link_map();
+}
+#else
+/* _dl_loaded isn't defined, so this should be either a libc5 (glibc1) system, or a glibc2 system that doesn't have the multiple load bug (i.e., RH6.0).*/
+int main() { printf("./conftest1.so\n"); }
+#endif
+EOF
+
+	    $PERL -p -i -e "s/CURDIR/\$ENV{_curdir}/g;" conftest.C
+
+	    cat >> conftest1.C <<\EOF
+#include <stdio.h>
+void foo(void) {printf("foo in dll called\n");}
+EOF
+	    ${CXX-g++} -fPIC -c -g conftest1.C
+	    ${CXX-g++} -shared -Wl,-h -Wl,conftest1.so -o conftest1.so conftest1.o
+	    ${CXX-g++} -g conftest.C -o conftest -ldl
+	    cp -f conftest1.so conftest _conftest
+	    cd _conftest
+	    if test `./conftest | grep conftest1.so | wc -l` -gt 1
+	    then
+		echo
+		echo "*** Your libc has a bug that can result in loading the same dynamic"
+		echo "*** library multiple times.  This bug is known to be fixed in glibc-2.0.7-32"
+		echo "*** or later.  However, if you choose not to upgrade, the only effect"
+		echo "*** will be excessive memory usage at runtime."
+		echo
+	    fi
+	    cd ${_curdir}
+	    rm -rf conftest* _conftest
+	    dnl ===================================================================
+	    ;;
+esac
+
+dnl ===================================================================
+dnl ========================================================
+dnl By default, turn rtti and exceptions off on g++/egcs
+dnl ========================================================
+if test "$GNU_CXX"; then
+
+  AC_MSG_CHECKING(for C++ exceptions flag)
+
+  dnl They changed -f[no-]handle-exceptions to -f[no-]exceptions in g++ 2.8
+  AC_CACHE_VAL(ac_cv_cxx_exceptions_flags,
+  [echo "int main() { return 0; }" | cat > conftest.C
+
+  ${CXX-g++} ${CXXFLAGS} -c -fno-handle-exceptions conftest.C > conftest.out 2>&1
+
+  if egrep "warning.*renamed" conftest.out >/dev/null; then
+    ac_cv_cxx_exceptions_flags=${_COMPILER_PREFIX}-fno-exceptions
+  else
+    ac_cv_cxx_exceptions_flags=${_COMPILER_PREFIX}-fno-handle-exceptions
+  fi
+
+  rm -f conftest*])
+
+  AC_MSG_RESULT($ac_cv_cxx_exceptions_flags)
+  _MOZ_EXCEPTIONS_FLAGS_OFF=$ac_cv_cxx_exceptions_flags
+  _MOZ_EXCEPTIONS_FLAGS_ON=`echo $ac_cv_cxx_exceptions_flags | sed 's|no-||'`
+fi
+
+dnl ========================================================
+dnl Put your C++ language/feature checks below
+dnl ========================================================
+AC_LANG_CPLUSPLUS
+
+HAVE_GCC3_ABI=
+if test "$GNU_CC"; then
+  AC_CACHE_CHECK(for gcc 3.0 ABI,
+      ac_cv_gcc_three_abi,
+      [AC_TRY_COMPILE([],
+                      [
+#if defined(__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100 /* G++ V3 ABI */
+  return 0;
+#else
+#error Not gcc3.
+#endif
+                      ],
+                      ac_cv_gcc_three_abi="yes",
+                      ac_cv_gcc_three_abi="no")])
+  if test "$ac_cv_gcc_three_abi" = "yes"; then
+      TARGET_COMPILER_ABI="${TARGET_COMPILER_ABI-gcc3}"
+      HAVE_GCC3_ABI=1
+  else
+      TARGET_COMPILER_ABI="${TARGET_COMPILER_ABI-gcc2}"
+  fi
+fi
+AC_SUBST(HAVE_GCC3_ABI)
+
+
+AC_CACHE_CHECK(for C++ \"explicit\" keyword,
+               ac_cv_cpp_explicit,
+               [AC_TRY_COMPILE(class X {
+                               public: explicit X(int i) : i_(i) {}
+                               private: int i_;
+                               };,
+                               X x(3);,
+                               ac_cv_cpp_explicit=yes,
+                               ac_cv_cpp_explicit=no)])
+if test "$ac_cv_cpp_explicit" = yes ; then
+   AC_DEFINE(HAVE_CPP_EXPLICIT)
+fi
+
+AC_CACHE_CHECK(for C++ \"typename\" keyword,
+               ac_cv_cpp_typename,
+               [AC_TRY_COMPILE(class param {
+                               public:
+                                   typedef unsigned long num_type;
+                               };
+
+                               template <class T> class tplt {
+                               public:
+                                   typedef typename T::num_type t_num_type;
+                                   t_num_type foo(typename T::num_type num) {
+                                       return num;
+                                   }
+                               };,
+                               tplt<param> A;
+                               A.foo(0);,
+                               ac_cv_cpp_typename=yes,
+                               ac_cv_cpp_typename=no)])
+if test "$ac_cv_cpp_typename" = yes ; then
+   AC_DEFINE(HAVE_CPP_TYPENAME)
+fi
+
+dnl Check for support of modern template specialization syntax
+dnl Test code and requirement from scc@netscape.com.
+dnl Autoconf cut-and-paste job by waterson@netscape.com
+AC_CACHE_CHECK(for modern C++ template specialization syntax support,
+               ac_cv_cpp_modern_specialize_template_syntax,
+               [AC_TRY_COMPILE(template <class T> struct X { int a; };
+                               class Y {};
+                               template <> struct X<Y> { double a; };,
+                               X<int> int_x;
+                               X<Y> y_x;,
+                               ac_cv_cpp_modern_specialize_template_syntax=yes,
+                               ac_cv_cpp_modern_specialize_template_syntax=no)])
+if test "$ac_cv_cpp_modern_specialize_template_syntax" = yes ; then
+  AC_DEFINE(HAVE_CPP_MODERN_SPECIALIZE_TEMPLATE_SYNTAX)
+fi
+
+
+dnl Some compilers support only full specialization, and some don't.
+AC_CACHE_CHECK(whether partial template specialization works,
+               ac_cv_cpp_partial_specialization,
+               [AC_TRY_COMPILE(template <class T> class Foo {};
+                               template <class T> class Foo<T*> {};,
+                               return 0;,
+                               ac_cv_cpp_partial_specialization=yes,
+                               ac_cv_cpp_partial_specialization=no)])
+if test "$ac_cv_cpp_partial_specialization" = yes ; then
+  AC_DEFINE(HAVE_CPP_PARTIAL_SPECIALIZATION)
+fi
+
+dnl Some compilers have limited support for operators with templates;
+dnl specifically, it is necessary to define derived operators when a base
+dnl class's operator declaration should suffice.
+AC_CACHE_CHECK(whether operators must be re-defined for templates derived from templates,
+               ac_cv_need_derived_template_operators,
+               [AC_TRY_COMPILE([template <class T> class Base { };
+                                template <class T>
+                                Base<T> operator+(const Base<T>& lhs, const Base<T>& rhs) { return lhs; }
+                                template <class T> class Derived : public Base<T> { };],
+                               [Derived<char> a, b;
+                                Base<char> c = a + b;
+                                return 0;],
+                               ac_cv_need_derived_template_operators=no,
+                               ac_cv_need_derived_template_operators=yes)])
+if test "$ac_cv_need_derived_template_operators" = yes ; then
+  AC_DEFINE(NEED_CPP_DERIVED_TEMPLATE_OPERATORS)
+fi
+
+
+dnl Some compilers have trouble detecting that a template class
+dnl that derives from another template is actually an instance
+dnl of the base class. This test checks for that.
+AC_CACHE_CHECK(whether we need to cast a derived template to pass as its base class,
+               ac_cv_need_cpp_template_cast_to_base,
+               [AC_TRY_COMPILE([template <class T> class Base { };
+                                template <class T> class Derived : public Base<T> { };
+                                template <class T> int foo(const Base<T>&) { return 0; }],
+                               [Derived<char> bar; return foo(bar);],
+                               ac_cv_need_cpp_template_cast_to_base=no,
+                               ac_cv_need_cpp_template_cast_to_base=yes)])
+if test "$ac_cv_need_cpp_template_cast_to_base" = yes ; then
+  AC_DEFINE(NEED_CPP_TEMPLATE_CAST_TO_BASE)
+fi
+
+dnl Some compilers have trouble resolving the ambiguity between two
+dnl functions whose arguments differ only by cv-qualifications.
+AC_CACHE_CHECK(whether the compiler can resolve const ambiguities for templates,
+               ac_cv_can_resolve_const_ambiguity,
+               [AC_TRY_COMPILE([
+                                template <class T> class ptrClass {
+                                  public: T* ptr;
+                                };
+
+                                template <class T> T* a(ptrClass<T> *arg) {
+                                  return arg->ptr;
+                                }
+
+                                template <class T>
+                                const T* a(const ptrClass<T> *arg) {
+                                  return arg->ptr;
+                                }
+                               ],
+                               [ ptrClass<int> i;
+                                 a(&i); ],
+                               ac_cv_can_resolve_const_ambiguity=yes,
+                               ac_cv_can_resolve_const_ambiguity=no)])
+if test "$ac_cv_can_resolve_const_ambiguity" = no ; then
+  AC_DEFINE(CANT_RESOLVE_CPP_CONST_AMBIGUITY)
+fi
+
+dnl
+dnl We don't do exceptions on unix.  The only reason this used to be here
+dnl is that mozilla/xpcom/tests/TestCOMPtr.cpp has a test which uses 
+dnl exceptions.  But, we turn exceptions off by default and this test breaks.
+dnl So im commenting this out until someone writes some artificial 
+dnl intelligence to detect not only if the compiler has exceptions, but if 
+dnl they are enabled as well.
+dnl 
+dnl AC_CACHE_CHECK(for C++ \"exceptions\",
+dnl                ac_cv_cpp_exceptions,
+dnl                [AC_TRY_COMPILE(class X { public: X() {} };
+dnl                                static void F() { throw X(); },
+dnl                                try { F(); } catch(X & e) { },
+dnl                                ac_cv_cpp_exceptions=yes,
+dnl                                ac_cv_cpp_exceptions=no)])
+dnl if test $ac_cv_cpp_exceptions = yes ; then
+dnl    AC_DEFINE(HAVE_CPP_EXCEPTIONS)
+dnl fi
+
+dnl Some compilers have marginal |using| support; for example, gcc-2.7.2.3
+dnl supports it well enough to allow us to use it to change access, but not
+dnl to resolve ambiguity. The next two tests determine how well the |using|
+dnl keyword is supported.
+dnl
+dnl Check to see if we can change access with |using|.  Test both a
+dnl legal and an illegal example.
+AC_CACHE_CHECK(whether the C++ \"using\" keyword can change access,
+               ac_cv_cpp_access_changing_using2,
+               [AC_TRY_COMPILE(
+                   class A { protected: int foo() { return 0; } };
+                   class B : public A { public: using A::foo; };,
+                   B b; return b.foo();,
+                   [AC_TRY_COMPILE(
+                       class A { public: int foo() { return 1; } };
+                       class B : public A { private: using A::foo; };,
+                       B b; return b.foo();,
+                       ac_cv_cpp_access_changing_using2=no,
+                       ac_cv_cpp_access_changing_using2=yes)],
+                   ac_cv_cpp_access_changing_using2=no)])
+if test "$ac_cv_cpp_access_changing_using2" = yes ; then
+   AC_DEFINE(HAVE_CPP_ACCESS_CHANGING_USING)
+fi
+
+dnl Check to see if we can resolve ambiguity with |using|.
+AC_CACHE_CHECK(whether the C++ \"using\" keyword resolves ambiguity,
+               ac_cv_cpp_ambiguity_resolving_using,
+               [AC_TRY_COMPILE(class X { 
+                                 public: int go(const X&) {return 3;}
+                                         int jo(const X&) {return 3;}
+                               };
+                               class Y : public X {
+                                 public:  int go(int) {return 2;}
+                                          int jo(int) {return 2;}
+                                          using X::jo;
+                                 private: using X::go;
+                               };,
+                               X x; Y y; y.jo(x);,
+                               ac_cv_cpp_ambiguity_resolving_using=yes,
+                               ac_cv_cpp_ambiguity_resolving_using=no)])
+if test "$ac_cv_cpp_ambiguity_resolving_using" = yes ; then
+   AC_DEFINE(HAVE_CPP_AMBIGUITY_RESOLVING_USING)
+fi
+
+dnl Check to see if the |std| namespace is supported. If so, we'll want
+dnl to qualify any standard library calls with "std::" to ensure that
+dnl those functions can be resolved.
+AC_CACHE_CHECK(for \"std::\" namespace,
+               ac_cv_cpp_namespace_std,
+               [AC_TRY_COMPILE([#include <algorithm>],
+                               [return std::min(0, 1);],
+                               ac_cv_cpp_namespace_std=yes,
+                               ac_cv_cpp_namespace_std=no)])
+if test "$ac_cv_cpp_namespace_std" = yes ; then
+   AC_DEFINE(HAVE_CPP_NAMESPACE_STD)
+fi
+
+dnl Older compilers are overly ambitious with respect to using the standard
+dnl template library's |operator!=()| when |operator==()| is defined. In
+dnl which case, defining |operator!=()| in addition to |operator==()| causes
+dnl ambiguity at compile-time. This test checks for that case.
+AC_CACHE_CHECK(whether standard template operator!=() is ambiguous,
+               ac_cv_cpp_unambiguous_std_notequal,
+               [AC_TRY_COMPILE([#include <algorithm>
+                                struct T1 {};
+                                int operator==(const T1&, const T1&) { return 0; }
+                                int operator!=(const T1&, const T1&) { return 0; }],
+                               [T1 a,b; return a != b;],
+                               ac_cv_cpp_unambiguous_std_notequal=unambiguous,
+                               ac_cv_cpp_unambiguous_std_notequal=ambiguous)])
+if test "$ac_cv_cpp_unambiguous_std_notequal" = unambiguous ; then
+  AC_DEFINE(HAVE_CPP_UNAMBIGUOUS_STD_NOTEQUAL)
+fi
+
+
+AC_CACHE_CHECK(for C++ reinterpret_cast,
+               ac_cv_cpp_reinterpret_cast,
+               [AC_TRY_COMPILE(struct X { int i; };
+                               struct Y { int i; };,
+                               X x; X*const z = &x;Y*y = reinterpret_cast<Y*>(z);,
+                               ac_cv_cpp_reinterpret_cast=yes,
+                               ac_cv_cpp_reinterpret_cast=no)])
+if test "$ac_cv_cpp_reinterpret_cast" = yes ; then
+   AC_DEFINE(HAVE_CPP_NEW_CASTS)
+fi
+
+dnl See if a dynamic_cast to void* gives the most derived object.
+AC_CACHE_CHECK(for C++ dynamic_cast to void*,
+               ac_cv_cpp_dynamic_cast_void_ptr,
+               [AC_TRY_RUN([class X { int i; public: virtual ~X() { } };
+                            class Y { int j; public: virtual ~Y() { } };
+                            class Z : public X, public Y { int k; };
+
+                            int main() {
+                                 Z mdo;
+                                 X *subx = (X*)&mdo;
+                                 Y *suby = (Y*)&mdo;
+                                 return !((((void*)&mdo != (void*)subx) &&
+                                           ((void*)&mdo == dynamic_cast<void*>(subx))) ||
+                                          (((void*)&mdo != (void*)suby) &&
+                                           ((void*)&mdo == dynamic_cast<void*>(suby))));
+                            }],
+                           ac_cv_cpp_dynamic_cast_void_ptr=yes,
+                           ac_cv_cpp_dynamic_cast_void_ptr=no,
+                           ac_cv_cpp_dynamic_cast_void_ptr=no)])
+if test "$ac_cv_cpp_dynamic_cast_void_ptr" = yes ; then
+   AC_DEFINE(HAVE_CPP_DYNAMIC_CAST_TO_VOID_PTR)
+fi
+
+
+dnl note that this one is reversed - if the test fails, then
+dnl we require implementations of unused virtual methods. Which
+dnl really blows because it means we'll have useless vtable
+dnl bloat.
+AC_CACHE_CHECK(whether C++ requires implementation of unused virtual methods,
+               ac_cv_cpp_unused_required,
+               [AC_TRY_LINK(class X {private: virtual void never_called();};,
+                               X x;,
+                               ac_cv_cpp_unused_required=no,
+                               ac_cv_cpp_unused_required=yes)])
+if test "$ac_cv_cpp_unused_required" = yes ; then
+   AC_DEFINE(NEED_CPP_UNUSED_IMPLEMENTATIONS)
+fi
+
+
+dnl Some compilers have trouble comparing a constant reference to a templatized
+dnl class to zero, and require an explicit operator==() to be defined that takes
+dnl an int. This test separates the strong from the weak.
+
+AC_CACHE_CHECK(for trouble comparing to zero near std::operator!=(),
+               ac_cv_trouble_comparing_to_zero,
+               [AC_TRY_COMPILE([#include <algorithm>
+                                template <class T> class Foo {};
+                                class T2;
+                                template <class T> int operator==(const T2*, const T&) { return 0; }
+                                template <class T> int operator!=(const T2*, const T&) { return 0; }],
+                               [Foo<int> f; return (0 != f);],
+                               ac_cv_trouble_comparing_to_zero=no,
+                               ac_cv_trouble_comparing_to_zero=yes)])
+if test "$ac_cv_trouble_comparing_to_zero" = yes ; then
+  AC_DEFINE(HAVE_CPP_TROUBLE_COMPARING_TO_ZERO)
+fi
+
+
+
+dnl End of C++ language/feature checks
+AC_LANG_C
+
+dnl ========================================================
+dnl =  Internationalization checks
+dnl ========================================================
+dnl
+dnl Internationalization and Locale support is different
+dnl on various UNIX platforms.  Checks for specific i18n
+dnl features go here.
+
+dnl check for LC_MESSAGES
+AC_CACHE_CHECK(for LC_MESSAGES,
+		ac_cv_i18n_lc_messages,
+		[AC_TRY_COMPILE([#include <locale.h>],
+				[int category = LC_MESSAGES;],
+				ac_cv_i18n_lc_messages=yes,
+				ac_cv_i18n_lc_messages=no)])
+if test "$ac_cv_i18n_lc_messages" = yes; then
+   AC_DEFINE(HAVE_I18N_LC_MESSAGES)
+fi 	
+
+fi # SKIP_COMPILER_CHECKS
+
+TARGET_XPCOM_ABI=
+if test -n "${CPU_ARCH}" -a -n "${TARGET_COMPILER_ABI}"; then
+    TARGET_XPCOM_ABI="${CPU_ARCH}-${TARGET_COMPILER_ABI}"
+fi
+
+dnl Mozilla specific options
+dnl ========================================================
+dnl The macros used for command line options
+dnl are defined in build/autoconf/altoptions.m4.
+
+
+dnl ========================================================
+dnl =
+dnl = Check for external package dependencies
+dnl =
+dnl ========================================================
+MOZ_ARG_HEADER(External Packages)
+
+MOZ_ENABLE_LIBXUL=
+
+MOZ_ARG_WITH_STRING(libxul-sdk,
+[  --with-libxul-sdk=PFX   Use the libXUL SDK at <PFX>],
+  LIBXUL_SDK_DIR=$withval)
+
+if test "$LIBXUL_SDK_DIR" = "yes"; then
+    AC_MSG_ERROR([--with-libxul-sdk must specify a path])
+elif test -n "$LIBXUL_SDK_DIR" -a "$LIBXUL_SDK_DIR" != "no"; then
+    LIBXUL_SDK=`cd "$LIBXUL_SDK_DIR" && pwd`
+
+    if test ! -f "$LIBXUL_SDK/sdk/include/xpcom-config.h"; then
+        AC_MSG_ERROR([$LIBXUL_SDK/sdk/include/xpcom-config.h doesn't exist])
+    fi
+
+    MOZ_ENABLE_LIBXUL=1
+fi
+AC_SUBST(LIBXUL_SDK)
+
+dnl ========================================================
+dnl = If NSPR was not detected in the system, 
+dnl = use the one in the source tree (mozilla/nsprpub)
+dnl ========================================================
+MOZ_ARG_WITH_BOOL(system-nspr,
+[  --with-system-nspr      Use system installed NSPR],
+    _USE_SYSTEM_NSPR=1 )
+
+if test -n "$_USE_SYSTEM_NSPR"; then
+    AM_PATH_NSPR(4.7.0, [MOZ_NATIVE_NSPR=1], [MOZ_NATIVE_NSPR=])
+fi
+
+if test -n "$MOZ_NATIVE_NSPR"; then
+    _SAVE_CFLAGS=$CFLAGS
+    CFLAGS="$CFLAGS $NSPR_CFLAGS"
+    AC_TRY_COMPILE([#include "prlog.h"],
+                [#ifndef PR_STATIC_ASSERT
+                 #error PR_STATIC_ASSERT not defined
+                 #endif],
+                [MOZ_NATIVE_NSPR=1],
+                AC_MSG_ERROR([system NSPR does not support PR_STATIC_ASSERT]))
+    CFLAGS=$_SAVE_CFLAGS
+else
+    NSPR_CFLAGS='`$(DEPTH)/mozilla/nsprpub/config/nspr-config --prefix=$(LIBXUL_DIST) --includedir=$(LIBXUL_DIST)/include/nspr --cflags`'
+    # explicitly set libs for Visual Age C++ for OS/2
+    if test "$OS_ARCH" = "OS2" -a "$VACPP" = "yes"; then
+        NSPR_LIBS='$(LIBXUL_DIST)/lib/nspr'$NSPR_VERSION'.lib $(LIBXUL_DIST)/lib/plc'$NSPR_VERSION'.lib $(LIBXUL_DIST)/lib/plds'$NSPR_VERSION'.lib '$_PTHREAD_LDFLAGS''
+    elif test "$OS_ARCH" = "WINCE"; then
+        NSPR_CFLAGS='-I$(LIBXUL_DIST)/include/nspr'
+        NSPR_LIBS='$(LIBXUL_DIST)/lib/nspr'$NSPR_VERSION'.lib $(LIBXUL_DIST)/lib/plc'$NSPR_VERSION'.lib $(LIBXUL_DIST)/lib/plds'$NSPR_VERSION'.lib '
+    elif test "$OS_ARCH" = "WINNT"; then
+        NSPR_CFLAGS='-I$(LIBXUL_DIST)/include/nspr'
+        if test -n "$GNU_CC"; then
+            NSPR_LIBS="-L\$(LIBXUL_DIST)/lib -lnspr$NSPR_VERSION -lplc$NSPR_VERSION -lplds$NSPR_VERSION"
+        else
+            NSPR_LIBS='$(LIBXUL_DIST)/lib/nspr'$NSPR_VERSION'.lib $(LIBXUL_DIST)/lib/plc'$NSPR_VERSION'.lib $(LIBXUL_DIST)/lib/plds'$NSPR_VERSION'.lib '
+        fi
+    else
+        NSPR_LIBS='`$(DEPTH)/mozilla/nsprpub/config/nspr-config --prefix=$(LIBXUL_DIST) --libdir=$(LIBXUL_DIST)/lib --libs`'
+    fi
+fi
+
+dnl ========================================================
+dnl = If NSS was not detected in the system, 
+dnl = use the one in the source tree (mozilla/security/nss)
+dnl ========================================================
+
+MOZ_ARG_WITH_BOOL(system-nss,
+[  --with-system-nss      Use system installed NSS],
+    _USE_SYSTEM_NSS=1 )
+
+if test -n "$_USE_SYSTEM_NSS"; then
+    AM_PATH_NSS(3.12.0, [MOZ_NATIVE_NSS=1], [MOZ_NATIVE_NSS=])
+fi
+
+if test -n "$MOZ_NATIVE_NSS"; then
+   NSS_LIBS="$NSS_LIBS -lcrmf"
+else
+   NSS_CFLAGS='-I$(LIBXUL_DIST)/include/nss'
+   NSS_DEP_LIBS="\
+        \$(LIBXUL_DIST)/lib/\$(LIB_PREFIX)crmf.\$(LIB_SUFFIX) \
+        \$(LIBXUL_DIST)/lib/\$(DLL_PREFIX)smime$NSS_VERSION\$(DLL_SUFFIX) \
+        \$(LIBXUL_DIST)/lib/\$(DLL_PREFIX)ssl$NSS_VERSION\$(DLL_SUFFIX) \
+        \$(LIBXUL_DIST)/lib/\$(DLL_PREFIX)nss$NSS_VERSION\$(DLL_SUFFIX) \
+        \$(LIBXUL_DIST)/lib/\$(DLL_PREFIX)nssutil$NSS_VERSION\$(DLL_SUFFIX) \
+        \$(LIBXUL_DIST)/lib/\$(DLL_PREFIX)softokn$NSS_VERSION\$(DLL_SUFFIX)"
+
+   if test -z "$GNU_CC" && test "$OS_ARCH" = "WINNT" -o "$OS_ARCH" = "WINCE" -o "$OS_ARCH" = "OS2"; then
+       NSS_LIBS="\
+        \$(LIBXUL_DIST)/lib/\$(LIB_PREFIX)crmf.\$(LIB_SUFFIX) \
+        \$(LIBXUL_DIST)/lib/\$(LIB_PREFIX)smime$NSS_VERSION.\$(IMPORT_LIB_SUFFIX) \
+        \$(LIBXUL_DIST)/lib/\$(LIB_PREFIX)ssl$NSS_VERSION.\$(IMPORT_LIB_SUFFIX) \
+        \$(LIBXUL_DIST)/lib/\$(LIB_PREFIX)nss$NSS_VERSION.\$(IMPORT_LIB_SUFFIX) \
+        \$(LIBXUL_DIST)/lib/\$(LIB_PREFIX)nssutil$NSS_VERSION.\$(IMPORT_LIB_SUFFIX) \
+        \$(LIBXUL_DIST)/lib/\$(LIB_PREFIX)softokn$NSS_VERSION.\$(IMPORT_LIB_SUFFIX)"
+   else
+       NSS_LIBS='$(LIBS_DIR)'" -lcrmf -lsmime$NSS_VERSION -lssl$NSS_VERSION -lnss$NSS_VERSION -lnssutil$NSS_VERSION -lsoftokn$NSS_VERSION"
+   fi
+fi
+
+if test -z "$SKIP_LIBRARY_CHECKS"; then
+dnl system JPEG support
+dnl ========================================================
+MOZ_ARG_WITH_STRING(system-jpeg,
+[  --with-system-jpeg[=PFX]
+                          Use system libjpeg [installed at prefix PFX]],
+    JPEG_DIR=$withval)
+
+_SAVE_CFLAGS=$CFLAGS
+_SAVE_LDFLAGS=$LDFLAGS
+_SAVE_LIBS=$LIBS
+if test -n "${JPEG_DIR}" -a "${JPEG_DIR}" != "yes"; then
+    CFLAGS="-I${JPEG_DIR}/include $CFLAGS"
+    LDFLAGS="-L${JPEG_DIR}/lib $LDFLAGS"
+fi
+if test -z "$JPEG_DIR" -o "$JPEG_DIR" = no; then
+    SYSTEM_JPEG=
+else
+    AC_CHECK_LIB(jpeg, jpeg_destroy_compress, [SYSTEM_JPEG=1 JPEG_LIBS="-ljpeg $JPEG_LIBS"], SYSTEM_JPEG=, $JPEG_LIBS)
+fi
+
+if test "$SYSTEM_JPEG" = 1; then
+    LIBS="$JPEG_LIBS $LIBS"
+    AC_TRY_COMPILE([ #include <stdio.h>
+                     #include <sys/types.h>
+                     #include <jpeglib.h> ],
+                   [ #if JPEG_LIB_VERSION < $MOZJPEG
+                     #error "Insufficient JPEG library version ($MOZJPEG required)."
+                     #endif ],
+                   SYSTEM_JPEG=1,
+                   [SYSTEM_JPEG= JPEG_CFLAGS= JPEG_LIBS=]) 
+fi 
+CFLAGS=$_SAVE_CFLAGS
+LDFLAGS=$_SAVE_LDFLAGS
+LIBS=$_SAVE_LIBS
+
+if test -n "${JPEG_DIR}" -a -d "${JPEG_DIR}" -a "$SYSTEM_JPEG" = 1; then
+    JPEG_CFLAGS="-I${JPEG_DIR}/include"
+    JPEG_LIBS="-L${JPEG_DIR}/lib ${JPEG_LIBS}"
+fi
+
+dnl system ZLIB support
+dnl ========================================================
+MOZ_ARG_WITH_STRING(system-zlib,
+[  --with-system-zlib[=PFX]
+                          Use system libz [installed at prefix PFX]],
+    ZLIB_DIR=$withval)
+
+_SAVE_CFLAGS=$CFLAGS
+_SAVE_LDFLAGS=$LDFLAGS
+_SAVE_LIBS=$LIBS
+if test -n "${ZLIB_DIR}" -a "${ZLIB_DIR}" != "yes"; then
+    CFLAGS="-I${ZLIB_DIR}/include $CFLAGS"
+    LDFLAGS="-L${ZLIB_DIR}/lib $LDFLAGS"
+fi
+if test -z "$ZLIB_DIR" -o "$ZLIB_DIR" = no; then
+    SYSTEM_ZLIB=
+else
+    AC_CHECK_LIB(z, gzread, [SYSTEM_ZLIB=1 ZLIB_LIBS="-lz $ZLIB_LIBS"], 
+	[SYSTEM_ZLIB= ZLIB_CFLAGS= ZLIB_LIBS=], $ZLIB_LIBS)
+fi
+if test "$SYSTEM_ZLIB" = 1; then
+    LIBS="$ZLIB_LIBS $LIBS"
+    AC_TRY_COMPILE([ #include <stdio.h>
+                     #include <string.h>
+                     #include <zlib.h> ],
+                   [ #if ZLIB_VERNUM < $MOZZLIB 
+                     #error "Insufficient zlib version ($MOZZLIB required)."
+                     #endif ],
+                   SYSTEM_ZLIB=1,
+                   [SYSTEM_ZLIB= ZLIB_CFLAGS= ZLIB_LIBS=]) 
+fi
+CFLAGS=$_SAVE_CFLAGS
+LDFLAGS=$_SAVE_LDFLAGS
+LIBS=$_SAVE_LIBS
+
+if test "${ZLIB_DIR}" -a -d "${ZLIB_DIR}" -a "$SYSTEM_ZLIB" = 1; then
+    ZLIB_CFLAGS="-I${ZLIB_DIR}/include"
+    ZLIB_LIBS="-L${ZLIB_DIR}/lib ${ZLIB_LIBS}"
+fi
+
+dnl system BZIP2 Support
+dnl ========================================================
+MOZ_ARG_WITH_STRING(system-bz2,
+[  --with-system-bz2[=PFX]
+                          Use system libbz2 [installed at prefix PFX]],
+    BZ2_DIR=$withval)
+
+_SAVE_CFLAGS=$CFLAGS
+_SAVE_LDFLAGS=$LDFLAGS
+_SAVE_LIBS=$LIBS
+if test -n "${BZ2_DIR}" -a "${BZ2_DIR}" != "yes"; then
+    CFLAGS="-I${BZ2_DIR}/include $CFLAGS"
+    LDFLAGS="-L${BZ2_DIR}/lib $LDFLAGS"
+fi
+if test -z "$BZ2_DIR" -o "$BZ2_DIR" = no; then
+    SYSTEM_BZ2=
+else
+    AC_CHECK_LIB(bz2, BZ2_bzread, [SYSTEM_BZ2=1 BZ2_LIBS="-lbz2"],
+	[SYSTEM_BZ2= BZ2_CFLAGS= BZ2_LIBS=], $BZ2_LIBS)
+fi
+CFLAGS=$_SAVE_CFLAGS
+LDFLAGS=$_SAVE_LDFLAGS
+LIBS=$_SAVE_LIBS
+
+if test "${BZ2_DIR}" -a -d "${BZ2_DIR}" -a "$SYSTEM_BZ2" = 1; then
+    BZ2_CFLAGS="-I${BZ2_DIR}/include"
+    BZ2_LIBS="-L${BZ2_DIR}/lib ${MOZ_BZ2_LIBS}"
+fi
+
+dnl system PNG Support
+dnl ========================================================
+MOZ_ARG_WITH_STRING(system-png, 
+[  --with-system-png[=PFX]
+                          Use system libpng [installed at prefix PFX]],
+    PNG_DIR=$withval)
+
+_SAVE_CFLAGS=$CFLAGS
+_SAVE_LDFLAGS=$LDFLAGS
+_SAVE_LIBS=$LIBS
+CFLAGS="$ZLIB_CFLAGS $CFLAGS"
+LDFLAGS="$ZLIB_LIBS -lz $LDFLAGS"
+if test -n "${PNG_DIR}" -a "${PNG_DIR}" != "yes"; then
+    CFLAGS="-I${PNG_DIR}/include $CFLAGS"
+    LDFLAGS="-L${PNG_DIR}/lib $LDFLAGS"
+fi
+if test -z "$PNG_DIR" -o "$PNG_DIR" = no; then
+    SYSTEM_PNG=
+else
+    _SAVE_PNG_LIBS=$PNG_LIBS
+    AC_CHECK_LIB(png, png_get_valid, [SYSTEM_PNG=1 PNG_LIBS="-lpng $PNG_LIBS"],
+                 AC_MSG_ERROR([--with-system-png requested but no working libpng found]), 
+                 $PNG_LIBS)
+    AC_CHECK_LIB(png, png_get_acTL, ,
+                 AC_MSG_ERROR([--with-system-png won't work because the system's libpng doesn't have APNG support]),
+                 $_SAVE_PNG_LIBS)
+fi
+if test "$SYSTEM_PNG" = 1; then
+    LIBS="$PNG_LIBS $LIBS"
+    AC_TRY_COMPILE([ #include <stdio.h>
+                     #include <sys/types.h>
+                     #include <png.h> ],
+                   [ #if PNG_LIBPNG_VER < $MOZPNG
+                     #error "Insufficient libpng version ($MOZPNG required)."
+                     #endif
+                     #ifndef PNG_UINT_31_MAX
+                     #error "Insufficient libpng version."
+                     #endif ],
+                   SYSTEM_PNG=1,
+                   AC_MSG_ERROR([--with-system-png requested but no working libpng found]))
+fi
+CFLAGS=$_SAVE_CFLAGS
+LDFLAGS=$_SAVE_LDFLAGS
+LIBS=$_SAVE_LIBS
+
+if test "${PNG_DIR}" -a -d "${PNG_DIR}" -a "$SYSTEM_PNG" = 1; then
+    PNG_CFLAGS="-I${PNG_DIR}/include"
+    PNG_LIBS="-L${PNG_DIR}/lib ${PNG_LIBS}"
+fi
+
+fi # SKIP_LIBRARY_CHECKS
+
+dnl system HunSpell Support
+dnl ========================================================
+MOZ_ARG_ENABLE_BOOL(system-hunspell,
+[  --enable-system-hunspell  Use system hunspell (located with pkgconfig)],
+    SYSTEM_HUNSPELL=1 )
+
+if test -n "$SYSTEM_HUNSPELL"; then
+    PKG_CHECK_MODULES(MOZ_HUNSPELL, hunspell)
+fi
+
+AC_SUBST(SYSTEM_HUNSPELL)
+
+dnl check whether to enable glitz
+dnl ========================================================
+MOZ_ARG_ENABLE_BOOL(glitz,
+[  --enable-glitz          Enable Glitz for use with Cairo],
+    MOZ_ENABLE_GLITZ=1,
+    MOZ_ENABLE_GLITZ= )
+if test "$MOZ_ENABLE_GLITZ"; then
+    AC_DEFINE(MOZ_ENABLE_GLITZ)
+fi
+
+dnl ========================================================
+dnl Java SDK support
+dnl ========================================================
+JAVA_INCLUDE_PATH=
+MOZ_ARG_WITH_STRING(java-include-path,
+[  --with-java-include-path=dir   Location of Java SDK headers],
+    JAVA_INCLUDE_PATH=$withval)
+
+JAVA_BIN_PATH=
+MOZ_ARG_WITH_STRING(java-bin-path,
+[  --with-java-bin-path=dir   Location of Java binaries (java, javac, jar)],
+    JAVA_BIN_PATH=$withval)
+
+dnl ========================================================
+dnl Use ARM userspace kernel helpers; tell NSPR to enable
+dnl their usage and use them in spidermonkey.
+dnl ========================================================
+MOZ_ARG_WITH_BOOL(arm-kuser,
+[  --with-arm-kuser         Use kuser helpers (Linux/ARM only -- requires kernel 2.6.13 or later)],
+    USE_ARM_KUSER=1,
+    USE_ARM_KUSER=)
+if test -n "$USE_ARM_KUSER"; then
+   AC_DEFINE(USE_ARM_KUSER)
+fi
+
+dnl ========================================================
+dnl =
+dnl = Application
+dnl =
+dnl ========================================================
+
+MOZ_ARG_HEADER(Application)
+
+BUILD_STATIC_LIBS=
+ENABLE_TESTS=1
+MOZ_ACTIVEX_SCRIPTING_SUPPORT=
+MOZ_BRANDING_DIRECTORY=
+MOZ_CALENDAR=
+MOZ_DBGRINFO_MODULES=
+MOZ_ENABLE_CANVAS=1
+MOZ_EXTENSIONS_ALL=" wallet p3p venkman inspector irc typeaheadfind gnomevfs sroaming datetime finger cview layout-debug tasks sql xforms schema-validation reporter"
+MOZ_FEEDS=1
+MOZ_IMG_DECODERS_DEFAULT="png gif jpeg bmp xbm icon"
+MOZ_IMG_ENCODERS_DEFAULT="png jpeg"
+MOZ_IPCD=
+MOZ_JAVAXPCOM=
+MOZ_JSDEBUGGER=1
+MOZ_JSLOADER=1
+MOZ_LDAP_XPCOM=
+MOZ_LIBART_CFLAGS=
+MOZ_LIBART_LIBS=
+MOZ_MAIL_NEWS=
+MOZ_MATHML=1
+MOZ_MOCHITEST=1
+MOZ_MORK=1
+MOZ_MORKREADER=
+MOZ_AUTH_EXTENSION=1
+MOZ_NO_ACTIVEX_SUPPORT=1
+MOZ_NO_INSPECTOR_APIS=
+MOZ_NO_XPCOM_OBSOLETE=
+MOZ_NO_FAST_LOAD=
+MOZ_OJI=
+MOZ_PERMISSIONS=1
+MOZ_PLACES=
+MOZ_PLAINTEXT_EDITOR_ONLY=
+MOZ_PLUGINS=1
+MOZ_PREF_EXTENSIONS=1
+MOZ_PROFILELOCKING=1
+MOZ_PROFILESHARING=1
+MOZ_PSM=1
+MOZ_PYTHON_EXTENSIONS="xpcom dom"
+MOZ_PYTHON=
+MOZ_PYTHON_DEBUG_SUFFIX=
+MOZ_PYTHON_DLL_SUFFIX=
+MOZ_PYTHON_INCLUDES=
+MOZ_PYTHON_LIBS=
+MOZ_PYTHON_PREFIX=
+MOZ_PYTHON_VER=
+MOZ_PYTHON_VER_DOTTED=
+MOZ_RDF=1
+MOZ_REFLOW_PERF=
+MOZ_SAFE_BROWSING=
+MOZ_HELP_VIEWER=
+MOZ_SPELLCHECK=1
+MOZ_STATIC_MAIL_BUILD=
+MOZ_STORAGE=1
+MOZ_SVG=1
+MOZ_TIMELINE=
+MOZ_UI_LOCALE=en-US
+MOZ_UNIVERSALCHARDET=1
+MOZ_URL_CLASSIFIER=
+MOZ_USE_NATIVE_UCONV=
+MOZ_V1_STRING_ABI=
+MOZ_VIEW_SOURCE=1
+MOZ_XPFE_COMPONENTS=1
+MOZ_XPINSTALL=1
+MOZ_XSLT_STANDALONE=
+MOZ_XTF=1
+MOZ_XUL=1
+MOZ_XUL_APP=1
+MOZ_ZIPWRITER=1
+NS_PRINTING=1
+SUNCTL=
+JS_STATIC_BUILD=
+XPC_IDISPATCH_SUPPORT=
+
+
+case "$target_os" in
+darwin*)
+    ACCESSIBILITY=
+    ;;
+*)
+    ACCESSIBILITY=1
+    ;;
+esac
+
+case "$target_os" in
+    msvc*|mks*|cygwin*|mingw*)
+        if test -z "$GNU_CC"; then 
+            XPC_IDISPATCH_SUPPORT=1
+            MOZ_NO_ACTIVEX_SUPPORT=
+            MOZ_ACTIVEX_SCRIPTING_SUPPORT=1
+        fi
+        ;;
+esac
+
+MOZ_ARG_ENABLE_STRING(application,
+[  --enable-application=APP
+                          Options include:
+                            suite (SeaMonkey)
+                            mail (Thunderbird)
+                            calendar (Sunbird)],
+[ MOZ_BUILD_APP=$enableval ] )
+
+MOZ_EMBEDDING_PROFILE=default
+MOZ_ARG_WITH_STRING(embedding-profile,
+[  --with-embedding-profile=default|basic|minimal
+                       see http://wiki.mozilla.org/Gecko:Small_Device_Support],
+[ MOZ_EMBEDDING_PROFILE=$withval ])
+
+case "$MOZ_EMBEDDING_PROFILE" in
+default)
+  MOZ_EMBEDDING_LEVEL_DEFAULT=1
+  MOZ_EMBEDDING_LEVEL_BASIC=1
+  MOZ_EMBEDDING_LEVEL_MINIMAL=1
+  AC_DEFINE(MOZ_EMBEDDING_LEVEL_DEFAULT)
+  AC_DEFINE(MOZ_EMBEDDING_LEVEL_BASIC)
+  AC_DEFINE(MOZ_EMBEDDING_LEVEL_MINIMAL)
+  ;;
+
+basic)
+  MOZ_EMBEDDING_LEVEL_DEFAULT=
+  MOZ_EMBEDDING_LEVEL_BASIC=1
+  MOZ_EMBEDDING_LEVEL_MINIMAL=1
+  AC_DEFINE(MOZ_EMBEDDING_LEVEL_BASIC)
+  AC_DEFINE(MOZ_EMBEDDING_LEVEL_MINIMAL)
+  ENABLE_TESTS=
+  MOZ_ACTIVEX_SCRIPTING_SUPPORT=
+  MOZ_COMPOSER=
+  MOZ_ENABLE_CANVAS=
+  MOZ_ENABLE_POSTSCRIPT=
+  MOZ_EXTENSIONS_DEFAULT=" spatialnavigation"
+  MOZ_IMG_DECODERS_DEFAULT="png gif jpeg"
+  MOZ_IMG_ENCODERS_DEFAULT=
+  MOZ_IMG_ENCODERS=
+  MOZ_INSTALLER=
+  MOZ_JSDEBUGGER=
+  MOZ_LDAP_XPCOM=
+  MOZ_MAIL_NEWS=
+  MOZ_MATHML=
+  MOZ_AUTH_EXTENSION=
+  MOZ_NO_ACTIVEX_SUPPORT=1
+  MOZ_NO_INSPECTOR_APIS=1
+  MOZ_NO_XPCOM_OBSOLETE=1
+  MOZ_NO_FAST_LOAD=1
+  MOZ_OJI=
+  MOZ_PLAINTEXT_EDITOR_ONLY=1
+#  MOZ_PLUGINS=
+  MOZ_PREF_EXTENSIONS=
+  MOZ_PROFILELOCKING=
+  MOZ_PROFILESHARING=
+  MOZ_SPELLCHECK=
+  MOZ_SVG=
+  MOZ_UNIVERSALCHARDET=
+  MOZ_UPDATER=
+  MOZ_USE_NATIVE_UCONV=
+  MOZ_VIEW_SOURCE=
+  MOZ_XPFE_COMPONENTS=
+  MOZ_XPINSTALL=
+  MOZ_XTF=
+  MOZ_ZIPWRITER=
+  NECKO_DISK_CACHE=
+  NECKO_PROTOCOLS_DEFAULT="about data http file res"
+  NECKO_SMALL_BUFFERS=1
+  NS_DISABLE_LOGGING=1
+  NS_PRINTING=
+  JS_STATIC_BUILD=1
+  ;;
+
+minimal)
+  MOZ_EMBEDDING_LEVEL_DEFAULT=
+  MOZ_EMBEDDING_LEVEL_BASIC=
+  MOZ_EMBEDDING_LEVEL_MINIMAL=1
+  AC_DEFINE(MOZ_EMBEDDING_LEVEL_MINIMAL)
+  ENABLE_TESTS=
+  MOZ_ACTIVEX_SCRIPTING_SUPPORT=
+  MOZ_COMPOSER=
+  MOZ_ENABLE_CANVAS=
+  MOZ_ENABLE_POSTSCRIPT=
+  MOZ_EXTENSIONS_DEFAULT=" spatialnavigation"
+  MOZ_IMG_DECODERS_DEFAULT="png gif jpeg"
+  MOZ_IMG_ENCODERS_DEFAULT=
+  MOZ_IMG_ENCODERS=
+  MOZ_INSTALLER=
+  MOZ_JSDEBUGGER=
+  MOZ_LDAP_XPCOM=
+  MOZ_MAIL_NEWS=
+  MOZ_MATHML=
+  MOZ_AUTH_EXTENSION=
+  MOZ_NO_ACTIVEX_SUPPORT=1
+  MOZ_NO_INSPECTOR_APIS=1
+  MOZ_NO_XPCOM_OBSOLETE=1
+  MOZ_NO_FAST_LOAD=1
+  MOZ_OJI=
+  MOZ_PLAINTEXT_EDITOR_ONLY=1
+  MOZ_PLUGINS=
+  MOZ_PREF_EXTENSIONS=
+  MOZ_PROFILELOCKING=
+  MOZ_PROFILESHARING=
+  MOZ_SPELLCHECK=
+  MOZ_STORAGE=1
+  MOZ_PLACES=
+  MOZ_SVG=
+  MOZ_UNIVERSALCHARDET=
+  MOZ_UPDATER=
+  MOZ_USE_NATIVE_UCONV=1
+  MOZ_VIEW_SOURCE=
+  MOZ_XPFE_COMPONENTS=
+  MOZ_XPINSTALL=
+  MOZ_XTF=
+  MOZ_XUL=
+  MOZ_ZIPWRITER=
+  MOZ_RDF=
+  NECKO_DISK_CACHE=
+  NECKO_PROTOCOLS_DEFAULT="about data http file res"
+  NECKO_SMALL_BUFFERS=1
+  NS_DISABLE_LOGGING=1
+  NS_PRINTING=
+  JS_STATIC_BUILD=1
+  ;;
+
+*)
+  AC_MSG_ERROR([Unrecognized value: --with-embedding-profile=$MOZ_EMBEDDING_PROFILE])
+  ;;
+esac
+
+AC_SUBST(MOZ_EMBEDDING_LEVEL_DEFAULT)
+AC_SUBST(MOZ_EMBEDDING_LEVEL_BASIC)
+AC_SUBST(MOZ_EMBEDDING_LEVEL_MINIMAL)
+
+MOZ_ARG_WITH_STRING(xulrunner-stub-name,
+[  --with-xulrunner-stub-name=appname   Create the xulrunner stub with the given name],
+  XULRUNNER_STUB_NAME=$withval)
+
+if test -z "$XULRUNNER_STUB_NAME"; then
+  case "$target_os" in
+  darwin*)
+    XULRUNNER_STUB_NAME=xulrunner
+    ;;
+  *)
+    XULRUNNER_STUB_NAME=xulrunner-stub
+  esac
+fi
+AC_SUBST(XULRUNNER_STUB_NAME)
+
+if test -z "$MOZ_BUILD_APP"; then
+  AC_MSG_ERROR([--enable-application=APP was not specified and is required.])
+else
+  # We have a valid application only if it has a build.mk file in its top
+  # directory.
+  if test ! -f "${srcdir}/${MOZ_BUILD_APP}/build.mk" ; then
+    AC_MSG_ERROR([--enable-application value not recognized (${MOZ_BUILD_APP}/build.mk does not exist).])
+  fi
+fi
+
+# Allow the application to influence configure with a confvars.sh script.
+
+AC_MSG_CHECKING([if app-specific confvars.sh exists])
+if test -f "${srcdir}/${MOZ_BUILD_APP}/confvars.sh" ; then
+  AC_MSG_RESULT([${srcdir}/${MOZ_BUILD_APP}/confvars.sh])
+  . "${srcdir}/${MOZ_BUILD_APP}/confvars.sh"
+else
+  AC_MSG_RESULT([no])
+fi
+
+# Now is a good time to test for logic errors, define mismatches, etc.
+case "$MOZ_BUILD_APP" in
+xulrunner)
+  if test "$LIBXUL_SDK"; then
+    AC_MSG_ERROR([Building XULRunner --with-libxul-sdk doesn't make sense; XULRunner provides the libxul SDK.])
+  fi
+  ;;
+*)
+  # Fix this case for folks who forget. Warn them.
+  if test -n "$LIBXUL_SDK" -a -z "$MOZ_XUL_APP"; then
+    AC_MSG_WARN([Setting MOZ_XUL_APP since LIBXUL_SDK was set. Add to confvars.sh!])
+    MOZ_XUL_APP=1
+  fi
+  ;;
+esac
+
+# Special cases where we need to AC_DEFINE something. Also a holdover for apps
+# that haven't made a confvars.sh yet. Don't add new stuff here, use
+# MOZ_BUILD_APP.
+case "$MOZ_BUILD_APP" in
+suite)
+  AC_DEFINE(MOZ_SUITE)
+  ;;
+
+mail)
+  AC_DEFINE(MOZ_THUNDERBIRD)
+  ;;
+
+calendar)
+  AC_DEFINE(MOZ_SUNBIRD)
+  ;;
+
+esac
+
+AC_SUBST(MOZ_BUILD_APP)
+AC_SUBST(MOZ_XUL_APP)
+AC_SUBST(MOZ_SUITE)
+AC_SUBST(MOZ_THUNDERBIRD)
+AC_SUBST(MOZ_SUNBIRD)
+
+AC_DEFINE_UNQUOTED(MOZ_BUILD_APP,$MOZ_BUILD_APP)
+
+if test "$MOZ_XUL_APP"; then
+  MOZ_PROFILESHARING=
+  AC_DEFINE(MOZ_XUL_APP)
+fi
+
+dnl ========================================================
+dnl = 
+dnl = Toolkit Options
+dnl = 
+dnl ========================================================
+MOZ_ARG_HEADER(Toolkit Options)
+
+    dnl ========================================================
+    dnl = Select the default toolkit
+    dnl ========================================================
+	MOZ_ARG_ENABLE_STRING(default-toolkit,
+	[  --enable-default-toolkit=TK
+                          Select default toolkit
+                          Platform specific defaults:
+                            BeOS - cairo-beos
+                            Mac OS X - cairo-cocoa
+                            Neutrino/QNX - photon
+                            OS/2 - cairo-os2
+                            Win32 - cairo-windows
+                            WinCE - windows
+                            * - cairo-gtk2],
+    [ _DEFAULT_TOOLKIT=$enableval ],
+    [ _DEFAULT_TOOLKIT=$_PLATFORM_DEFAULT_TOOLKIT])
+
+    if test "$_DEFAULT_TOOLKIT" = "photon" \
+        -o "$_DEFAULT_TOOLKIT" = "cairo-windows" \
+        -o "$_DEFAULT_TOOLKIT" = "cairo-gtk2" \
+        -o "$_DEFAULT_TOOLKIT" = "cairo-beos" \
+        -o "$_DEFAULT_TOOLKIT" = "cairo-os2" \
+        -o "$_DEFAULT_TOOLKIT" = "cairo-mac" \
+        -o "$_DEFAULT_TOOLKIT" = "cairo-cocoa"
+    then
+        dnl nglayout only supports building with one toolkit,
+        dnl so ignore everything after the first comma (",").
+        MOZ_WIDGET_TOOLKIT=`echo "$_DEFAULT_TOOLKIT" | sed -e "s/,.*$//"`
+    else
+        if test "$no_x" != "yes"; then
+            AC_MSG_ERROR([Toolkit must be cairo-gtk2.])
+        else
+            AC_MSG_ERROR([Toolkit must be $_PLATFORM_DEFAULT_TOOLKIT (if supported).])
+        fi
+    fi
+
+AC_DEFINE_UNQUOTED(MOZ_DEFAULT_TOOLKIT,"$MOZ_WIDGET_TOOLKIT")
+
+dnl ========================================================
+dnl = Enable the toolkit as needed                         =
+dnl ========================================================
+
+case "$MOZ_WIDGET_TOOLKIT" in
+photon)
+	MOZ_ENABLE_PHOTON=1
+	AC_DEFINE(MOZ_WIDGET_PHOTON)
+    ;;
+
+cairo-windows)
+    MOZ_WIDGET_TOOLKIT=windows
+    MOZ_GFX_TOOLKIT=cairo
+    ;;
+
+cairo-gtk2)
+    MOZ_WIDGET_TOOLKIT=gtk2
+    MOZ_GFX_TOOLKIT=cairo
+    MOZ_ENABLE_GTK2=1
+    MOZ_ENABLE_XREMOTE=1
+    TK_CFLAGS='$(MOZ_GTK2_CFLAGS)'
+    TK_LIBS='$(MOZ_GTK2_LIBS)'
+    AC_DEFINE(MOZ_WIDGET_GTK2)
+    ;;
+cairo-beos)
+    MOZ_WIDGET_TOOLKIT=beos
+    MOZ_GFX_TOOLKIT=cairo
+    TK_CFLAGS='$(MOZ_CAIRO_CFLAGS)'
+    TK_LIBS='$(MOZ_CAIRO_LIBS)'
+    ;;
+
+cairo-os2)
+    MOZ_WIDGET_TOOLKIT=os2
+    MOZ_GFX_TOOLKIT=cairo
+    TK_CFLAGS='$(MOZ_CAIRO_CFLAGS)'
+    TK_LIBS='$(MOZ_CAIRO_LIBS)'
+    ;;
+
+cairo-mac|cairo-cocoa)
+    if test "$MOZ_WIDGET_TOOLKIT" = "cairo-cocoa"; then
+        MOZ_WIDGET_TOOLKIT=cocoa
+        AC_DEFINE(MOZ_WIDGET_COCOA)
+        MOZ_ENABLE_COCOA=1
+    else
+        MOZ_WIDGET_TOOLKIT=mac
+    fi
+    MOZ_GFX_TOOLKIT=cairo
+    MOZ_USER_DIR="Mozilla"
+    AC_DEFINE(XP_MACOSX)
+    AC_DEFINE(TARGET_CARBON)
+    AC_DEFINE(TARGET_API_MAC_CARBON)
+    TK_LIBS='-framework Carbon'
+    TK_CFLAGS="-I${MACOS_SDK_DIR}/Developer/Headers/FlatCarbon"
+    CFLAGS="$CFLAGS $TK_CFLAGS"
+    CXXFLAGS="$CXXFLAGS $TK_CFLAGS"
+    ;;
+esac
+
+if test "$MOZ_ENABLE_XREMOTE"; then
+    AC_DEFINE(MOZ_ENABLE_XREMOTE)
+fi
+
+if test "$COMPILE_ENVIRONMENT"; then
+if test "$MOZ_ENABLE_GTK2"
+then
+    PKG_CHECK_MODULES(MOZ_GTK2, gtk+-2.0 >= $GTK2_VERSION gtk+-unix-print-2.0 gdk-x11-2.0 glib-2.0 gobject-2.0)
+fi
+fi # COMPILE_ENVIRONMENT
+
+AC_SUBST(MOZ_DEFAULT_TOOLKIT)
+
+dnl ========================================================
+dnl = startup-notification support module
+dnl ========================================================
+
+if test "$MOZ_ENABLE_GTK2"
+then
+    MOZ_ENABLE_STARTUP_NOTIFICATION=
+
+    MOZ_ARG_ENABLE_BOOL(startup-notification,
+    [  --enable-startup-notification       Enable startup-notification support (default: disabled) ],
+        MOZ_ENABLE_STARTUP_NOTIFICATION=force,
+        MOZ_ENABLE_STARTUP_NOTIFICATION=)
+    if test "$MOZ_ENABLE_STARTUP_NOTIFICATION"
+    then
+        PKG_CHECK_MODULES(MOZ_STARTUP_NOTIFICATION,
+                          libstartup-notification-1.0 >= $STARTUP_NOTIFICATION_VERSION,
+        [MOZ_ENABLE_STARTUP_NOTIFICATION=1], [
+            if test "$MOZ_ENABLE_STARTUP_NOTIFICATION" = "force"
+            then
+                AC_MSG_ERROR([* * * Could not find startup-notification >= $STARTUP_NOTIFICATION_VERSION])
+            fi
+            MOZ_ENABLE_STARTUP_NOTIFICATION=
+        ])
+    fi
+
+    if test "$MOZ_ENABLE_STARTUP_NOTIFICATION"; then
+        AC_DEFINE(MOZ_ENABLE_STARTUP_NOTIFICATION)
+    fi
+
+    TK_LIBS="$TK_LIBS $MOZ_STARTUP_NOTIFICATION_LIBS"
+fi
+AC_SUBST(MOZ_ENABLE_STARTUP_NOTIFICATION)
+AC_SUBST(MOZ_STARTUP_NOTIFICATION_CFLAGS)
+AC_SUBST(MOZ_STARTUP_NOTIFICATION_LIBS)
+
+AC_SUBST(GTK_CONFIG)
+AC_SUBST(TK_CFLAGS)
+AC_SUBST(TK_LIBS)
+
+AC_SUBST(MOZ_ENABLE_GTK2)
+AC_SUBST(MOZ_ENABLE_PHOTON)
+AC_SUBST(MOZ_ENABLE_COCOA)
+AC_SUBST(MOZ_ENABLE_GLITZ)
+AC_SUBST(MOZ_ENABLE_XREMOTE)
+AC_SUBST(MOZ_GTK2_CFLAGS)
+AC_SUBST(MOZ_GTK2_LIBS)
+
+AC_SUBST(MOC)
+
+if test "$MOZ_ENABLE_GTK2"
+then
+    AC_DEFINE(MOZ_X11)
+    MOZ_X11=1
+fi
+AC_SUBST(MOZ_X11)
+
+dnl ========================================================
+dnl =
+dnl = Components & Features
+dnl = 
+dnl ========================================================
+MOZ_ARG_HEADER(Components and Features)
+
+dnl ========================================================
+dnl = Localization
+dnl ========================================================
+MOZ_ARG_ENABLE_STRING(ui-locale,
+[  --enable-ui-locale=ab-CD
+                          Select the user interface locale (default: en-US)],
+    MOZ_UI_LOCALE=$enableval )
+AC_SUBST(MOZ_UI_LOCALE)
+
+dnl =========================================================
+dnl = Calendar client
+dnl =========================================================
+MOZ_ARG_ENABLE_BOOL(calendar,
+[  --enable-calendar      Enable building of the Lightning calendar extension],
+    MOZ_CALENDAR=1,
+    MOZ_CALENDAR= )
+AC_SUBST(MOZ_CALENDAR)
+
+dnl =========================================================
+dnl = Mail & News
+dnl =========================================================
+MOZ_ARG_DISABLE_BOOL(mailnews,
+[  --disable-mailnews      Disable building of mail & news components],
+    MOZ_MAIL_NEWS=,
+    MOZ_MAIL_NEWS=1 )
+AC_SUBST(MOZ_MAIL_NEWS)
+
+dnl =========================================================
+dnl = LDAP
+dnl =========================================================
+MOZ_ARG_DISABLE_BOOL(ldap,
+[  --disable-ldap          Disable LDAP support],
+    MOZ_LDAP_XPCOM=,
+    MOZ_LDAP_XPCOM=1)
+
+dnl ========================================================
+dnl = Trademarked Branding 
+dnl ========================================================
+MOZ_ARG_ENABLE_BOOL(official-branding,
+[  --enable-official-branding Enable Official mozilla.org Branding
+                          Do not distribute builds with
+                          --enable-official-branding unless you have
+                          permission to use trademarks per
+                          http://www.mozilla.org/foundation/trademarks/ .],
+[case "$MOZ_BUILD_APP" in
+calendar)
+    MOZ_BRANDING_DIRECTORY=other-licenses/branding/sunbird
+    MOZ_APP_DISPLAYNAME=Sunbird
+    ;;
+
+mail)
+    MOZ_BRANDING_DIRECTORY=other-licenses/branding/thunderbird
+    ;;
+
+*)]
+    AC_MSG_ERROR([Official branding is only available for Sunbird and Thunderbird.])
+esac
+)
+
+MOZ_ARG_WITH_STRING(branding,
+[  --with-branding=dir    Use branding from the specified directory.],
+    MOZ_BRANDING_DIRECTORY=$withval)
+
+REAL_BRANDING_DIRECTORY="${MOZ_BRANDING_DIRECTORY}"
+if test -z "$REAL_BRANDING_DIRECTORY"; then
+  REAL_BRANDING_DIRECTORY=${MOZ_BUILD_APP}/branding/nightly
+fi
+
+if test -f "$topsrcdir/$REAL_BRANDING_DIRECTORY/configure.sh"; then
+  . "$topsrcdir/$REAL_BRANDING_DIRECTORY/configure.sh"
+fi
+
+AC_SUBST(MOZ_BRANDING_DIRECTORY)
+
+dnl ========================================================
+dnl = Distribution ID
+dnl ========================================================
+MOZ_ARG_WITH_STRING(distribution-id,
+[  --with-distribution-id=ID  Set distribution-specific id (default=org.mozilla)],
+[ val=`echo $withval`
+    MOZ_DISTRIBUTION_ID="$val"])
+
+if test -z "$MOZ_DISTRIBUTION_ID"; then
+   MOZ_DISTRIBUTION_ID="org.mozilla"
+fi
+
+AC_DEFINE_UNQUOTED(MOZ_DISTRIBUTION_ID,"$MOZ_DISTRIBUTION_ID")
+AC_SUBST(MOZ_DISTRIBUTION_ID)
+
+dnl ========================================================
+dnl = Xft and Pango
+dnl ========================================================
+if test "$MOZ_ENABLE_GTK2"
+then
+    PKG_CHECK_MODULES(MOZ_XFT, xft)
+    AC_SUBST(MOZ_XFT_CFLAGS)
+    AC_SUBST(MOZ_XFT_LIBS)
+
+    PKG_CHECK_MODULES(_PANGOCHK, pango >= $PANGO_VERSION)
+    PKG_CHECK_MODULES(MOZ_PANGO, pango >= $PANGO_VERSION pangocairo >= $PANGO_VERSION pangoft2 >= $PANGO_VERSION)
+    AC_SUBST(MOZ_PANGO_CFLAGS)
+    AC_SUBST(MOZ_PANGO_LIBS)
+fi
+
+dnl ========================================================
+dnl = PostScript print module
+dnl ========================================================
+MOZ_ARG_DISABLE_BOOL(postscript,
+[  --disable-postscript    Disable PostScript printing support ],
+    MOZ_ENABLE_POSTSCRIPT=,
+    MOZ_ENABLE_POSTSCRIPT=1 )
+
+dnl ========================================================
+dnl = GnomeVFS support module
+dnl ========================================================
+
+if test "$MOZ_X11"
+then
+    dnl build the gnomevfs extension by default only when the
+    dnl GTK2 toolkit is in use.
+    if test "$MOZ_ENABLE_GTK2"
+    then
+        MOZ_ENABLE_GNOMEVFS=1
+        MOZ_ENABLE_GCONF=1
+        MOZ_ENABLE_LIBGNOME=1
+    fi
+
+    MOZ_ARG_DISABLE_BOOL(gnomevfs,
+    [  --disable-gnomevfs      Disable GnomeVFS support ],
+        MOZ_ENABLE_GNOMEVFS=,
+        MOZ_ENABLE_GNOMEVFS=force)
+
+    if test "$MOZ_ENABLE_GNOMEVFS"
+    then
+        PKG_CHECK_MODULES(MOZ_GNOMEVFS, gnome-vfs-2.0 >= $GNOMEVFS_VERSION gnome-vfs-module-2.0 >= $GNOMEVFS_VERSION,[
+            MOZ_GNOMEVFS_LIBS=`echo $MOZ_GNOMEVFS_LIBS | sed 's/-llinc\>//'`
+            MOZ_ENABLE_GNOMEVFS=1
+        ],[
+            if test "$MOZ_ENABLE_GNOMEVFS" = "force"
+            then
+                AC_MSG_ERROR([* * * Could not find gnome-vfs-module-2.0 >= $GNOMEVFS_VERSION])
+            fi
+            MOZ_ENABLE_GNOMEVFS=
+        ])
+    fi
+
+    AC_SUBST(MOZ_GNOMEVFS_CFLAGS)
+    AC_SUBST(MOZ_GNOMEVFS_LIBS)
+
+    if test "$MOZ_ENABLE_GCONF"
+    then
+        PKG_CHECK_MODULES(MOZ_GCONF, gconf-2.0 >= $GCONF_VERSION,[
+            MOZ_GCONF_LIBS=`echo $MOZ_GCONF_LIBS | sed 's/-llinc\>//'`
+            MOZ_ENABLE_GCONF=1
+        ],[
+            MOZ_ENABLE_GCONF=
+        ])
+    fi
+
+    if test "$MOZ_ENABLE_GCONF"; then
+        AC_DEFINE(MOZ_ENABLE_GCONF)
+    fi
+
+    AC_SUBST(MOZ_ENABLE_GCONF)
+    AC_SUBST(MOZ_GCONF_CFLAGS)
+    AC_SUBST(MOZ_GCONF_LIBS)
+
+    if test "$MOZ_ENABLE_LIBGNOME"
+    then
+        PKG_CHECK_MODULES(MOZ_LIBGNOME, libgnome-2.0 >= $LIBGNOME_VERSION,[
+            MOZ_LIBGNOME_LIBS=`echo $MOZ_LIBGNOME_LIBS | sed 's/-llinc\>//'`
+            MOZ_ENABLE_LIBGNOME=1
+        ],[
+            MOZ_ENABLE_LIBGNOME=
+        ])
+    fi
+
+    AC_SUBST(MOZ_LIBGNOME_CFLAGS)
+    AC_SUBST(MOZ_LIBGNOME_LIBS)
+
+    # The GNOME component is built if gtk2, gconf, gnome-vfs, and libgnome
+    # are all available.
+
+    if test "$MOZ_ENABLE_GTK2" -a "$MOZ_ENABLE_GCONF" -a \
+            "$MOZ_ENABLE_GNOMEVFS" -a "$MOZ_ENABLE_LIBGNOME"; then
+      MOZ_ENABLE_GNOME_COMPONENT=1
+    else
+      MOZ_ENABLE_GNOME_COMPONENT=
+    fi
+
+    AC_SUBST(MOZ_ENABLE_GNOME_COMPONENT)
+fi
+
+dnl ========================================================
+dnl = libgnomeui support module
+dnl ========================================================
+
+if test "$MOZ_ENABLE_GTK2"
+then
+    MOZ_ENABLE_GNOMEUI=1
+
+    MOZ_ARG_DISABLE_BOOL(gnomeui,
+    [  --disable-gnomeui       Disable libgnomeui support (default: auto, optional at runtime) ],
+        MOZ_ENABLE_GNOMEUI=,
+        MOZ_ENABLE_GNOMEUI=force)
+
+    if test "$MOZ_ENABLE_GNOMEUI"
+    then
+        PKG_CHECK_MODULES(MOZ_GNOMEUI, libgnomeui-2.0 >= $GNOMEUI_VERSION,
+        [
+            MOZ_GNOMEUI_LIBS=`echo $MOZ_GNOMEUI_LIBS | sed 's/-llinc\>//'`
+            MOZ_ENABLE_GNOMEUI=1
+        ],[
+            if test "$MOZ_ENABLE_GNOMEUI" = "force"
+            then
+                AC_MSG_ERROR([* * * Could not find libgnomeui-2.0 >= $GNOMEUI_VERSION])
+            fi
+            MOZ_ENABLE_GNOMEUI=
+        ])
+    fi
+
+    if test "$MOZ_ENABLE_GNOMEUI"; then
+        AC_DEFINE(MOZ_ENABLE_GNOMEUI)
+    fi
+fi
+AC_SUBST(MOZ_ENABLE_GNOMEUI)
+AC_SUBST(MOZ_GNOME