Bug 763987 - Normalize autoconf.mk.in. r=ted
☠☠ backed out by e96cc844629d ☠ ☠
authorMike Hommey <mh+mozilla@glandium.org>
Wed, 20 Jun 2012 09:00:48 +0200
changeset 97118 6984dace6afb50340fc5fcb112b1e85df9a25041
parent 97117 df4bbe5ffc47a3024792628791a21de4a93a7e9c
child 97119 85a4e915fc209d0fffdf6202e3b485bd79824494
push id862
push userpastithas@mozilla.com
push dateThu, 21 Jun 2012 07:13:20 +0000
treeherderfx-team@df2e5f99504a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersted
bugs763987
milestone16.0a1
Bug 763987 - Normalize autoconf.mk.in. r=ted
browser/app/Makefile.in
build/macosx/js-icc-flight.mk
build/macosx/universal/flight.mk
client.mk
config/autoconf.mk.in
config/baseconfig.mk
config/config.mk
configure.in
js/src/config/autoconf.mk.in
js/src/config/baseconfig.mk
js/src/config/check-sync-exceptions
js/src/config/config.mk
js/src/configure.in
layout/media/Makefile.in
mozglue/build/Makefile.in
mozglue/tests/Makefile.in
other-licenses/bsdiff/Makefile.in
rdf/tests/rdfcat/Makefile.in
rdf/tests/triplescat/Makefile.in
toolkit/library/Makefile.in
toolkit/mozapps/update/updater/Makefile.in
toolkit/toolkit-makefiles.sh
--- a/browser/app/Makefile.in
+++ b/browser/app/Makefile.in
@@ -50,17 +50,17 @@ DEFINES += -DXPCOM_GLUE
 STL_FLAGS=
 
 LIBS += \
 	$(EXTRA_DSO_LIBS) \
 	$(XPCOM_STANDALONE_GLUE_LDOPTS) \
 	$(NULL)
 
 ifdef MOZ_LINKER
-LIBS += $(ZLIB_LIBS)
+LIBS += $(MOZ_ZLIB_LIBS)
 endif
 
 ifndef MOZ_WINCONSOLE
 ifdef MOZ_DEBUG
 MOZ_WINCONSOLE = 1
 else
 MOZ_WINCONSOLE = 0
 endif
deleted file mode 100644
--- a/build/macosx/js-icc-flight.mk
+++ /dev/null
@@ -1,14 +0,0 @@
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-OBJDIR_ICC = $(MOZ_OBJDIR)/js-icc
-OBJDIR_X86 = $(MOZ_OBJDIR)/i386
-
-include $(OBJDIR_X86)/config/autoconf.mk
-include $(TOPSRCDIR)/config/config.mk
-
-# Just copy the icc-produced libmozjs.dylib over
-postflight_all:
-	echo "Postflight: copying libmozjs.dylib..."
-	$(INSTALL) $(OBJDIR_ICC)/dist/bin/libmozjs.dylib $(OBJDIR_X86)/dist/$(MOZ_MACBUNDLE_NAME)/Contents/MacOS/
--- a/build/macosx/universal/flight.mk
+++ b/build/macosx/universal/flight.mk
@@ -61,24 +61,24 @@ postflight_all:
 # 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_ARCH_1)/$(MOZ_PKG_APPNAME)/$(APPNAME)/$(APP_CONTENTS)/*.chk \
 	      $(DIST_ARCH_2)/$(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)/build/macosx/universal/fix-buildconfig $(FIX_MODE) \
+	$(topsrcdir)/build/macosx/universal/fix-buildconfig $(FIX_MODE) \
 	  $(DIST_ARCH_1)/$(MOZ_PKG_APPNAME)/$(APPNAME)/$(BUILDCONFIG) \
 	  $(DIST_ARCH_2)/$(MOZ_PKG_APPNAME)/$(APPNAME)/$(BUILDCONFIG)
 	mkdir -p $(DIST_UNI)/$(MOZ_PKG_APPNAME)
 	rm -f $(DIST_ARCH_2)/universal
 	ln -s $(DIST_UNI) $(DIST_ARCH_2)/universal
 	rm -rf $(DIST_UNI)/$(MOZ_PKG_APPNAME)/$(APPNAME)
-	$(TOPSRCDIR)/build/macosx/universal/unify \
+	$(topsrcdir)/build/macosx/universal/unify \
           --unify-with-sort "\.manifest$$" \
           --unify-with-sort "components\.list$$" \
 	  $(DIST_ARCH_1)/$(MOZ_PKG_APPNAME)/$(APPNAME) \
 	  $(DIST_ARCH_2)/$(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.
 ifdef ENABLE_TESTS
@@ -89,14 +89,14 @@ ifdef ENABLE_TESTS
 # automation.py differs because it hardcodes a path to
 # dist/bin. It doesn't matter which one we use.
 	if test -d $(DIST_ARCH_1)/test-package-stage -a                 \
                 -d $(DIST_ARCH_2)/test-package-stage; then              \
            cp $(DIST_ARCH_1)/test-package-stage/mochitest/automation.py \
              $(DIST_ARCH_2)/test-package-stage/mochitest/;              \
            cp $(DIST_ARCH_1)/test-package-stage/reftest/automation.py   \
              $(DIST_ARCH_2)/test-package-stage/reftest/;                \
-           $(TOPSRCDIR)/build/macosx/universal/unify                 \
+           $(topsrcdir)/build/macosx/universal/unify                 \
              --unify-with-sort "all-test-dirs\.list$$"               \
              $(DIST_ARCH_1)/test-package-stage                          \
              $(DIST_ARCH_2)/test-package-stage                          \
              $(DIST_UNI)/test-package-stage; fi
 endif
--- a/client.mk
+++ b/client.mk
@@ -214,24 +214,24 @@ endif
 realbuild 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); \
+	  $(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)"; \
+	  $(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))
@@ -333,17 +333,17 @@ depend:: $(OBJDIR)/Makefile $(OBJDIR)/co
 
 ####################################
 # Preflight
 
 realbuild 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); \
+	  $(MAKE) -f $(TOPSRCDIR)/$$mkfile preflight topsrcdir=$(TOPSRCDIR) OBJDIR=$(OBJDIR) MOZ_OBJDIR=$(MOZ_OBJDIR); \
 	done
 endif
 
 ####################################
 # Build it
 
 realbuild::  $(OBJDIR)/Makefile $(OBJDIR)/config.status check-sync-dirs-config
 	$(MOZ_MAKE)
@@ -357,41 +357,41 @@ realbuild::  $(OBJDIR)/Makefile $(OBJDIR
 
 ####################################
 # Postflight
 
 realbuild 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); \
+	  $(MAKE) -f $(TOPSRCDIR)/$$mkfile postflight topsrcdir=$(TOPSRCDIR) OBJDIR=$(OBJDIR) MOZ_OBJDIR=$(MOZ_OBJDIR); \
 	done
 endif
 
 endif # MOZ_CURRENT_PROJECT
 
 ####################################
 # Postflight, after building all projects
 
 realbuild 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); \
+	  $(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)"; \
+	  $(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 ; \
--- a/config/autoconf.mk.in
+++ b/config/autoconf.mk.in
@@ -1,18 +1,15 @@
 #
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 # A netscape style .mk file for autoconf builds
 
-INCLUDED_AUTOCONF_MK = 1
-USE_AUTOCONF 	= 1
-MOZILLA_CLIENT	= 1
 target          = @target@
 ac_configure_args = @ac_configure_args@
 MOZILLA_VERSION = @MOZILLA_VERSION@
 FIREFOX_VERSION	= @FIREFOX_VERSION@
 
 MOZ_BUILD_APP = @MOZ_BUILD_APP@
 MOZ_APP_NAME	= @MOZ_APP_NAME@
 MOZ_APP_DISPLAYNAME = @MOZ_APP_DISPLAYNAME@
@@ -31,26 +28,21 @@ MOZ_MACBUNDLE_NAME = @MOZ_MACBUNDLE_NAME
 MOZ_MACBUNDLE_ID = @MOZ_MACBUNDLE_ID@
 MOZ_APP_STATIC_INI = @MOZ_APP_STATIC_INI@
 
 MOZ_PKG_SPECIAL = @MOZ_PKG_SPECIAL@
 
 prefix		= @prefix@
 exec_prefix	= @exec_prefix@
 bindir		= @bindir@
-includedir	= @includedir@/$(MOZ_APP_NAME)-$(MOZ_APP_VERSION)
+includedir	= @includedir@
 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)
-
-DIST		= $(DEPTH)/dist
 LIBXUL_SDK      = @LIBXUL_SDK@
 
 MOZ_FS_LAYOUT = @MOZ_FS_LAYOUT@
 
 L10NBASEDIR     = @L10NBASEDIR@
 
 LIBXUL_DIST	= @LIBXUL_DIST@
 SYSTEM_LIBXUL   = @SYSTEM_LIBXUL@
@@ -175,26 +167,24 @@ MOZ_D3DX9_VERSION = @MOZ_D3DX9_VERSION@
 MOZ_D3DX9_CAB = @MOZ_D3DX9_CAB@
 MOZ_D3DCOMPILER_CAB = @MOZ_D3DCOMPILER_CAB@
 MOZ_D3DX9_DLL = @MOZ_D3DX9_DLL@
 MOZ_D3DCOMPILER_DLL = @MOZ_D3DCOMPILER_DLL@
 MOZ_GL_PROVIDER = @MOZ_GL_PROVIDER@
 MOZ_GL_DEFAULT_PROVIDER = @MOZ_GL_DEFAULT_PROVIDER@
 
 
-JAVA="@JAVA@"
-JAVAC="@JAVAC@"
-JAR="@JAR@"
+JAVA=@JAVA@
+JAVAC=@JAVAC@
+JAR=@JAR@
 
 TAR=@TAR@
 
 MAKENSISU=@MAKENSISU@
 
-RM = rm -f
-
 # 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@
 
@@ -215,32 +205,32 @@ MOZ_BUILD_ROOT             = @MOZ_BUILD_
 
 MOZ_XUL                    = @MOZ_XUL@
 
 NECKO_PROTOCOLS = @NECKO_PROTOCOLS@
 NECKO_COOKIES = @NECKO_COOKIES@
 NECKO_WIFI = @NECKO_WIFI@
 MOZ_AUTH_EXTENSION = @MOZ_AUTH_EXTENSION@
 
-MOZ_NATIVE_HUNSPELL = @SYSTEM_HUNSPELL@
+MOZ_NATIVE_HUNSPELL = @MOZ_NATIVE_HUNSPELL@
 MOZ_HUNSPELL_LIBS = @MOZ_HUNSPELL_LIBS@
 MOZ_HUNSPELL_CFLAGS = @MOZ_HUNSPELL_CFLAGS@
 
 MOZ_NATIVE_LIBEVENT = @MOZ_NATIVE_LIBEVENT@
 MOZ_LIBEVENT_LIBS = @MOZ_LIBEVENT_LIBS@
 MOZ_LIBEVENT_INCLUDES = @MOZ_LIBEVENT_INCLUDES@
 
 MOZ_NATIVE_LIBVPX = @MOZ_NATIVE_LIBVPX@
 MOZ_LIBVPX_LIBS = @MOZ_LIBVPX_LIBS@
 MOZ_LIBVPX_INCLUDES = @MOZ_LIBVPX_INCLUDES@
 
-MOZ_NATIVE_ZLIB	= @SYSTEM_ZLIB@
-MOZ_NATIVE_BZ2	= @SYSTEM_BZ2@
-MOZ_NATIVE_JPEG	= @SYSTEM_JPEG@
-MOZ_NATIVE_PNG	= @SYSTEM_PNG@
+MOZ_NATIVE_ZLIB	= @MOZ_NATIVE_ZLIB@
+MOZ_NATIVE_BZ2	= @MOZ_NATIVE_BZ2@
+MOZ_NATIVE_JPEG	= @MOZ_NATIVE_JPEG@
+MOZ_NATIVE_PNG	= @MOZ_NATIVE_PNG@
 MOZ_TREE_CAIRO = @MOZ_TREE_CAIRO@
 MOZ_TREE_PIXMAN = @MOZ_TREE_PIXMAN@
 
 MOZ_UPDATE_XTERM = @MOZ_UPDATE_XTERM@
 MOZ_PERMISSIONS = @MOZ_PERMISSIONS@
 MOZ_XTF = @MOZ_XTF@
 MOZ_FLEXBOX = @MOZ_FLEXBOX@
 MOZ_SVG_DLISTS = @MOZ_SVG_DLISTS@
@@ -287,27 +277,26 @@ MOZ_NO_WLZDEFS = @MOZ_NO_WLZDEFS@
 
 BUILD_CTYPES = @BUILD_CTYPES@
 
 COMPILE_ENVIRONMENT = @COMPILE_ENVIRONMENT@
 CROSS_COMPILE   = @CROSS_COMPILE@
 
 WCHAR_CFLAGS	= @WCHAR_CFLAGS@
 
-OS_CPPFLAGS	= @CPPFLAGS@
-OS_CFLAGS	= $(OS_CPPFLAGS) @CFLAGS@
-OS_CXXFLAGS	= $(OS_CPPFLAGS) @CXXFLAGS@
-OS_LDFLAGS	= @LDFLAGS@
+OS_CPPFLAGS	= @OS_CPPFLAGS@
+OS_CFLAGS	= @OS_CFLAGS@
+OS_CXXFLAGS	= @OS_CXXFLAGS@
+OS_LDFLAGS	= @OS_LDFLAGS@
 
-OS_COMPILE_CFLAGS = $(OS_CPPFLAGS) @COMPILE_CFLAGS@
-OS_COMPILE_CXXFLAGS = $(OS_CPPFLAGS) @COMPILE_CXXFLAGS@
+OS_COMPILE_CFLAGS = @OS_COMPILE_CFLAGS@
+OS_COMPILE_CXXFLAGS = @OS_COMPILE_CXXFLAGS@
 
-OS_INCLUDES	= $(NSPR_CFLAGS) $(NSS_CFLAGS) $(JPEG_CFLAGS) $(PNG_CFLAGS) $(ZLIB_CFLAGS)
-OS_LIBS		= @LIBS@
-ACDEFINES	= @MOZ_DEFINES@
+OS_LIBS		= @OS_LIBS@
+ACDEFINES	= @ACDEFINES@
 
 WARNINGS_AS_ERRORS = @WARNINGS_AS_ERRORS@
 
 MOZ_OPTIMIZE	= @MOZ_OPTIMIZE@
 MOZ_FRAMEPTR_FLAGS = @MOZ_FRAMEPTR_FLAGS@
 MOZ_OPTIMIZE_FLAGS = @MOZ_OPTIMIZE_FLAGS@
 MOZ_PGO_OPTIMIZE_FLAGS = @MOZ_PGO_OPTIMIZE_FLAGS@
 MOZ_OPTIMIZE_LDFLAGS = @MOZ_OPTIMIZE_LDFLAGS@
@@ -348,20 +337,17 @@ 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@
-# We do magic with OBJ_SUFFIX in config.mk, the following ensures we don't
-# manually use it before config.mk inclusion
-OBJ_SUFFIX	= $(error config/config.mk needs to be included before using OBJ_SUFFIX)
-_OBJ_SUFFIX	= @OBJ_SUFFIX@
+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@
 LIBS_DESC_SUFFIX = @LIBS_DESC_SUFFIX@
 USE_N32		= @USE_N32@
 HAVE_64BIT_OS	= @HAVE_64BIT_OS@
@@ -416,53 +402,33 @@ PERL		= @PERL@
 PYTHON		= @PYTHON@
 RANLIB		= @RANLIB@
 OBJCOPY		= @OBJCOPY@
 UNZIP		= @UNZIP@
 ZIP		= @ZIP@
 XARGS		= @XARGS@
 STRIP		= @STRIP@
 DOXYGEN		= @DOXYGEN@
-PBBUILD_BIN	= @PBBUILD@
+PBBUILD_BIN	= @PBBUILD_BIN@
 SDP		= @SDP@
 NSINSTALL_BIN	= @NSINSTALL_BIN@
 WGET		= @WGET@
 RPMBUILD	= @RPMBUILD@
 
-ifdef MOZ_NATIVE_JPEG
-JPEG_CFLAGS	= @JPEG_CFLAGS@
-JPEG_LIBS	= @JPEG_LIBS@
-else
-JPEG_CFLAGS	= @MOZ_JPEG_CFLAGS@
-JPEG_LIBS	= @MOZ_JPEG_LIBS@
-endif
+MOZ_JPEG_CFLAGS	= @MOZ_JPEG_CFLAGS@
+MOZ_JPEG_LIBS	= @MOZ_JPEG_LIBS@
 
-ifdef MOZ_NATIVE_ZLIB
-ZLIB_CFLAGS	= @ZLIB_CFLAGS@
-ZLIB_LIBS	= @ZLIB_LIBS@
-else
-ZLIB_CFLAGS	= @MOZ_ZLIB_CFLAGS@
+MOZ_ZLIB_CFLAGS	= @MOZ_ZLIB_CFLAGS@
 MOZ_ZLIB_LIBS = @MOZ_ZLIB_LIBS@
-endif
 
-ifdef MOZ_NATIVE_BZ2
-BZ2_CFLAGS	= @BZ2_CFLAGS@
-BZ2_LIBS	= @BZ2_LIBS@
-else
-BZ2_CFLAGS	= @MOZ_BZ2_CFLAGS@
-BZ2_LIBS	= @MOZ_BZ2_LIBS@
-endif
+MOZ_BZ2_CFLAGS	= @MOZ_BZ2_CFLAGS@
+MOZ_BZ2_LIBS	= @MOZ_BZ2_LIBS@
 
-ifdef MOZ_NATIVE_PNG
-PNG_CFLAGS	= @PNG_CFLAGS@
-PNG_LIBS	= @PNG_LIBS@
-else
-PNG_CFLAGS	= @MOZ_PNG_CFLAGS@
-PNG_LIBS	= @MOZ_PNG_LIBS@
-endif
+MOZ_PNG_CFLAGS	= @MOZ_PNG_CFLAGS@
+MOZ_PNG_LIBS	= @MOZ_PNG_LIBS@
 
 QCMS_LIBS	= @QCMS_LIBS@
 
 MOZ_HARFBUZZ_LIBS = @MOZ_HARFBUZZ_LIBS@
 MOZ_GRAPHITE_LIBS = @MOZ_GRAPHITE_LIBS@
 MOZ_GRAPHITE = @MOZ_GRAPHITE@
 MOZ_OTS_LIBS = @MOZ_OTS_LIBS@
 MOZ_SKIA_LIBS = @MOZ_SKIA_LIBS@
@@ -509,19 +475,16 @@ DLL_SUFFIX              = @DLL_SUFFIX@
 
 NO_LD_ARCHIVE_FLAGS     = @NO_LD_ARCHIVE_FLAGS@
 
 GTK_CONFIG	= @GTK_CONFIG@
 QT_CONFIG	= @QT_CONFIG@
 TK_CFLAGS	= @TK_CFLAGS@
 TK_LIBS		= @TK_LIBS@
 
-MOZ_TOOLKIT_REGISTRY_CFLAGS = \
-	$(TK_CFLAGS)
-
 CAIRO_FT_CFLAGS		= @CAIRO_FT_CFLAGS@
 
 MOZ_TREE_FREETYPE		= @MOZ_TREE_FREETYPE@
 MOZ_ENABLE_CAIRO_FT	= @MOZ_ENABLE_CAIRO_FT@
 MOZ_ENABLE_GTK2		= @MOZ_ENABLE_GTK2@
 MOZ_ENABLE_QT		= @MOZ_ENABLE_QT@
 MOZ_ENABLE_XREMOTE	= @MOZ_ENABLE_XREMOTE@
 MOZ_ENABLE_DWRITE_FONT	= @MOZ_ENABLE_DWRITE_FONT@
@@ -572,19 +535,19 @@ MOZ_ENABLE_LIBNOTIFY	= @MOZ_ENABLE_LIBNO
 
 MOZ_ALSA_LIBS           = @MOZ_ALSA_LIBS@
 MOZ_ALSA_CFLAGS         = @MOZ_ALSA_CFLAGS@
 
 GLIB_CFLAGS	= @GLIB_CFLAGS@
 GLIB_LIBS	= @GLIB_LIBS@
 GLIB_GMODULE_LIBS	= @GLIB_GMODULE_LIBS@
 
-MOZ_NATIVE_MAKEDEPEND	= @SYSTEM_MAKEDEPEND@
+MOZ_NATIVE_MAKEDEPEND	= @MOZ_NATIVE_MAKEDEPEND@
 
-export CL_INCLUDES_PREFIX = @CL_INCLUDES_PREFIX@
+CL_INCLUDES_PREFIX = @CL_INCLUDES_PREFIX@
 
 MOZ_AUTO_DEPS	= @MOZ_AUTO_DEPS@
 COMPILER_DEPEND = @COMPILER_DEPEND@
 MDDEPDIR        := @MDDEPDIR@
 CC_WRAPPER = @CC_WRAPPER@
 CXX_WRAPPER = @CXX_WRAPPER@
 
 MOZ_DEMANGLE_SYMBOLS = @MOZ_DEMANGLE_SYMBOLS@
@@ -692,20 +655,9 @@ JS_SHARED_LIBRARY = @JS_SHARED_LIBRARY@
 MOZ_INSTRUMENT_EVENT_LOOP = @MOZ_INSTRUMENT_EVENT_LOOP@
 
 MOZ_SYSTEM_PLY = @MOZ_SYSTEM_PLY@
 
 MOZ_PACKAGE_JSSHELL = @MOZ_PACKAGE_JSSHELL@
 
 MOZ_LINKER_EXTRACT = @MOZ_LINKER_EXTRACT@
 
-# We only want to do the pymake sanity on Windows, other os's can cope
-ifeq ($(HOST_OS_ARCH),WINNT)
-# Ensure invariants between GNU Make and pymake
-# Checked here since we want the sane error in a file that
-# actually can be found regardless of path-style.
-ifeq (_:,$(.PYMAKE)_$(findstring :,$(srcdir)))
-$(error Windows-style srcdir being used with GNU make. Did you mean to run $(topsrcdir)/build/pymake/make.py instead? [see-also: https://developer.mozilla.org/en/Gmake_vs._Pymake])
-endif
-ifeq (1_a,$(.PYMAKE)_$(firstword a$(subst /, ,$(srcdir))))
-$(error MSYS-style srcdir being used with Pymake. Did you mean to run GNU Make instead? [see-also: https://developer.mozilla.org/en/Gmake_vs._Pymake])
-endif
-endif # WINNT
+include $(topsrcdir)/config/baseconfig.mk
new file mode 100644
--- /dev/null
+++ b/config/baseconfig.mk
@@ -0,0 +1,25 @@
+INCLUDED_AUTOCONF_MK = 1
+
+includedir := $(includedir)/$(MOZ_APP_NAME)-$(MOZ_APP_VERSION)
+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)
+DIST = $(DEPTH)/dist
+
+# We do magic with OBJ_SUFFIX in config.mk, the following ensures we don't
+# manually use it before config.mk inclusion
+_OBJ_SUFFIX := $(OBJ_SUFFIX)
+OBJ_SUFFIX = $(error config/config.mk needs to be included before using OBJ_SUFFIX)
+
+# We only want to do the pymake sanity on Windows, other os's can cope
+ifeq ($(HOST_OS_ARCH),WINNT)
+# Ensure invariants between GNU Make and pymake
+# Checked here since we want the sane error in a file that
+# actually can be found regardless of path-style.
+ifeq (_:,$(.PYMAKE)_$(findstring :,$(srcdir)))
+$(error Windows-style srcdir being used with GNU make. Did you mean to run $(topsrcdir)/build/pymake/make.py instead? [see-also:     https://developer.mozilla.org/en/Gmake_vs._Pymake])
+endif
+ifeq (1_a,$(.PYMAKE)_$(firstword a$(subst /, ,$(srcdir))))
+$(error MSYS-style srcdir being used with Pymake. Did you mean to run GNU Make instead? [see-also: https://developer.mozilla.org/    en/Gmake_vs._Pymake])
+endif
+endif # WINNT
--- a/config/config.mk
+++ b/config/config.mk
@@ -365,29 +365,31 @@ MY_RULES	:= $(DEPTH)/config/myrules.mk
 CCC = $(CXX)
 XPIDL_LINK = $(PYTHON) $(LIBXUL_DIST)/sdk/bin/xpt.py link
 
 # Java macros
 JAVA_GEN_DIR  = _javagen
 JAVA_DIST_DIR = $(DEPTH)/$(JAVA_GEN_DIR)
 JAVA_IFACES_PKG_NAME = org/mozilla/interfaces
 
+OS_INCLUDES += $(NSPR_CFLAGS) $(NSS_CFLAGS) $(MOZ_JPEG_CFLAGS) $(MOZ_PNG_CFLAGS) $(MOZ_ZLIB_CFLAGS)
+
 INCLUDES = \
   $(LOCAL_INCLUDES) \
   -I$(srcdir) \
   -I. \
   -I$(DIST)/include \
   $(if $(LIBXUL_SDK),-I$(LIBXUL_SDK)/include) \
   $(OS_INCLUDES) \
   $(NULL)
 
 include $(topsrcdir)/config/static-checking-config.mk
 
-CFLAGS		= $(OS_CFLAGS)
-CXXFLAGS	= $(OS_CXXFLAGS)
+CFLAGS		= $(OS_CPPFLAGS) $(OS_CFLAGS)
+CXXFLAGS	= $(OS_CPPFLAGS) $(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
@@ -484,18 +486,18 @@ HOST_CMMFLAGS += -fobjc-exceptions
 OS_COMPILE_CMFLAGS += -fobjc-exceptions
 OS_COMPILE_CMMFLAGS += -fobjc-exceptions
 ifeq ($(MOZ_WIDGET_TOOLKIT),uikit)
 OS_COMPILE_CMFLAGS += -fobjc-abi-version=2 -fobjc-legacy-dispatch
 OS_COMPILE_CMMFLAGS += -fobjc-abi-version=2 -fobjc-legacy-dispatch
 endif
 endif
 
-COMPILE_CFLAGS	= $(VISIBILITY_FLAGS) $(DEFINES) $(INCLUDES) $(DSO_CFLAGS) $(DSO_PIC_CFLAGS) $(CFLAGS) $(RTL_FLAGS) $(OS_COMPILE_CFLAGS)
-COMPILE_CXXFLAGS = $(STL_FLAGS) $(VISIBILITY_FLAGS) $(DEFINES) $(INCLUDES) $(DSO_CFLAGS) $(DSO_PIC_CFLAGS) $(CXXFLAGS) $(RTL_FLAGS) $(OS_COMPILE_CXXFLAGS)
+COMPILE_CFLAGS	= $(VISIBILITY_FLAGS) $(DEFINES) $(INCLUDES) $(DSO_CFLAGS) $(DSO_PIC_CFLAGS) $(CFLAGS) $(RTL_FLAGS) $(OS_CPPFLAGS) $(OS_COMPILE_CFLAGS)
+COMPILE_CXXFLAGS = $(STL_FLAGS) $(VISIBILITY_FLAGS) $(DEFINES) $(INCLUDES) $(DSO_CFLAGS) $(DSO_PIC_CFLAGS) $(CXXFLAGS) $(RTL_FLAGS) $(OS_CPPFLAGS) $(OS_COMPILE_CXXFLAGS)
 COMPILE_CMFLAGS = $(OS_COMPILE_CMFLAGS)
 COMPILE_CMMFLAGS = $(OS_COMPILE_CMMFLAGS)
 
 ifndef CROSS_COMPILE
 HOST_CFLAGS += $(RTL_FLAGS)
 endif
 
 #
@@ -788,8 +790,10 @@ EXPAND_LIBNAME = $(foreach lib,$(1),$(LI
 endif
 EXPAND_LIBNAME_PATH = $(foreach lib,$(1),$(2)/$(LIB_PREFIX)$(lib).$(LIB_SUFFIX))
 EXPAND_MOZLIBNAME = $(foreach lib,$(1),$(DIST)/lib/$(LIB_PREFIX)$(lib).$(LIB_SUFFIX))
 
 # Include internal ply only if needed
 ifndef MOZ_SYSTEM_PLY
 PLY_INCLUDE = -I$(topsrcdir)/other-licenses/ply
 endif
+
+export CL_INCLUDES_PREFIX
--- a/configure.in
+++ b/configure.in
@@ -868,17 +868,17 @@ MOZ_PATH_PROG(AUTOCONF, autoconf, :)
 MOZ_PATH_PROGS(UNZIP, unzip)
 if test -z "$UNZIP" -o "$UNZIP" = ":"; then
     AC_MSG_ERROR([unzip not found in \$PATH])
 fi
 MOZ_PATH_PROGS(ZIP, zip)
 if test -z "$ZIP" -o "$ZIP" = ":"; then
     AC_MSG_ERROR([zip not found in \$PATH])
 fi
-MOZ_PATH_PROG(SYSTEM_MAKEDEPEND, makedepend)
+MOZ_PATH_PROG(MOZ_NATIVE_MAKEDEPEND, makedepend)
 MOZ_PATH_PROG(XARGS, xargs)
 if test -z "$XARGS" -o "$XARGS" = ":"; then
     AC_MSG_ERROR([xargs not found in \$PATH .])
 fi
 
 MOZ_PATH_PROG(RPMBUILD, rpmbuild, :)
 AC_SUBST(RPMBUILD)
 
@@ -909,17 +909,17 @@ darwin*)
 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.
-    MOZ_PATH_PROGS(PBBUILD, pbbuild xcodebuild pbxbuild)
+    MOZ_PATH_PROGS(PBBUILD_BIN, pbbuild xcodebuild pbxbuild)
 
     dnl sdp was formerly in /Developer/Tools.  As of Mac OS X 10.4 (Darwin 8),
     dnl it has moved into /usr/bin.
     MOZ_PATH_PROG(SDP, sdp, :, [$PATH:/usr/bin:/Developer/Tools])
     ;;
 esac
 
 AC_SUBST(GCC_VERSION)
@@ -2094,17 +2094,17 @@ ia64*-hpux*)
        MKCSHLIB='$(CC) $(CFLAGS) $(DSO_LDOPTS) -o $@'
        CXXFLAGS="$CXXFLAGS -Wc,-ansi_for_scope,on"
     else
        DSO_LDOPTS='-b -E'
        MKSHLIB='$(LD) $(DSO_LDOPTS) -o $@'
        MKCSHLIB='$(LD) $(DSO_LDOPTS) -o $@'
     fi
     MOZ_FIX_LINK_PATHS=
-    SYSTEM_MAKEDEPEND=
+    MOZ_NATIVE_MAKEDEPEND=
     AC_DEFINE(NSCAP_DISABLE_DEBUG_PTR_TYPES)
     AC_DEFINE(_LARGEFILE64_SOURCE)
     ;;
 
 *-hpux*)
     DLL_SUFFIX=".sl"
     if test ! "$GNU_CC"; then
     	DSO_LDOPTS='-b -Wl,+s'
@@ -2183,17 +2183,17 @@ ia64*-hpux*)
 *-mingw*)
     DSO_CFLAGS=
     DSO_PIC_CFLAGS=
     DLL_SUFFIX=.dll
     RC=rc.exe
     MC=mc.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=
+    MOZ_NATIVE_MAKEDEPEND=
     if test -n "$GNU_CC"; then
         CC="$CC -mwindows"
         CXX="$CXX -mwindows"
         CPP="$CPP -mwindows"
         CFLAGS="$CFLAGS -mms-bitfields"
         CXXFLAGS="$CXXFLAGS -mms-bitfields"
         DSO_LDOPTS='-shared'
         MKSHLIB='$(CXX) $(DSO_LDOPTS) -o $@'
@@ -2464,17 +2464,17 @@ ia64*-hpux*)
     if test "$ac_os2_declspec" != "yes"; then
         AC_MSG_ERROR([Compiler does not support __declspec(dllexport), install GCC-4.3.2 or newer])
     fi
     ;;
 
 *-solaris*)
     AC_DEFINE(SOLARIS)
     TARGET_NSPR_MDCPUCFG='\"md/_solaris.cfg\"'
-    SYSTEM_MAKEDEPEND=
+    MOZ_NATIVE_MAKEDEPEND=
     MOZ_FIX_LINK_PATHS=
     # $ORIGIN/.. is for shared libraries under components/ to locate shared
     # libraries one level up (e.g. libnspr4.so)
     if test "$SOLARIS_SUNPRO_CC"; then
        LDFLAGS="$LDFLAGS -z ignore -R '\$\$ORIGIN:\$\$ORIGIN/..' -z lazyload -z combreloc -z muldefs"
        LIBS="-lCrun -lCstd -lc $LIBS"
        AC_DEFINE(NSCAP_DISABLE_DEBUG_PTR_TYPES)
        CFLAGS="$CFLAGS -xlibmieee -xstrconst -xbuiltin=%all -D__FUNCTION__=__func__"
@@ -4037,39 +4037,38 @@ MOZ_ARG_WITH_STRING(system-jpeg,
 _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=
+    MOZ_NATIVE_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_CHECK_LIB(jpeg, jpeg_destroy_compress, [MOZ_NATIVE_JPEG=1 MOZ_JPEG_LIBS="-ljpeg"], MOZ_NATIVE_JPEG=)
+fi
+
+if test "$MOZ_NATIVE_JPEG" = 1; then
     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,
+                   MOZ_NATIVE_JPEG=1,
                    AC_MSG_ERROR([Insufficient JPEG library version for --with-system-jpeg]))
 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}"
+if test -n "${JPEG_DIR}" -a -d "${JPEG_DIR}" -a "$MOZ_NATIVE_JPEG" = 1; then
+    MOZ_JPEG_CFLAGS="-I${JPEG_DIR}/include"
+    MOZ_JPEG_LIBS="-L${JPEG_DIR}/lib ${MOZ_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)
@@ -4077,43 +4076,42 @@ MOZ_ARG_WITH_STRING(system-zlib,
 _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=
+    MOZ_NATIVE_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_CHECK_LIB(z, gzread, [MOZ_NATIVE_ZLIB=1 MOZ_ZLIB_LIBS="-lz"],
+	[MOZ_NATIVE_ZLIB=])
+fi
+if test "$MOZ_NATIVE_ZLIB" = 1; then
     MOZZLIBNUM=`echo $MOZZLIB | awk -F. '{printf "0x%x\n", ((($1 * 16 + $2) * 16) + $3) * 16 + $4}'`
     AC_TRY_COMPILE([ #include <stdio.h>
                      #include <string.h>
                      #include <zlib.h> ],
                    [ #if ZLIB_VERNUM < $MOZZLIBNUM
                      #error "Insufficient zlib version ($MOZZLIBNUM required)."
                      #endif ],
-                   SYSTEM_ZLIB=1,
+                   MOZ_NATIVE_ZLIB=1,
                    AC_MSG_ERROR([Insufficient zlib version for --with-system-zlib ($MOZZLIB required)]))
 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
-
-if test "$MOZ_LINKER" = 1 -a "$SYSTEM_ZLIB" != 1; then
+if test "${ZLIB_DIR}" -a -d "${ZLIB_DIR}" -a "$MOZ_NATIVE_ZLIB" = 1; then
+    MOZ_ZLIB_CFLAGS="-I${ZLIB_DIR}/include"
+    MOZ_ZLIB_LIBS="-L${ZLIB_DIR}/lib ${ZLIB_LIBS}"
+fi
+
+if test "$MOZ_LINKER" = 1 -a "$MOZ_NATIVE_ZLIB" != 1; then
     AC_MSG_ERROR([Custom dynamic linker requires --with-system-zlib])
 fi
 
 dnl system BZIP2 Support
 dnl ========================================================
 MOZ_ARG_WITH_STRING(system-bz2,
 [  --with-system-bz2[=PFX]
                           Use system libbz2 [installed at prefix PFX]],
@@ -4122,94 +4120,88 @@ MOZ_ARG_WITH_STRING(system-bz2,
 _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=
+    MOZ_NATIVE_BZ2=
 else
-    AC_CHECK_LIB(bz2, BZ2_bzread, [SYSTEM_BZ2=1 BZ2_LIBS="-lbz2"],
-	[SYSTEM_BZ2= BZ2_CFLAGS= BZ2_LIBS=])
+    AC_CHECK_LIB(bz2, BZ2_bzread, [MOZ_NATIVE_BZ2=1 MOZ_BZ2_LIBS="-lbz2"],
+	[MOZ_NATIVE_BZ2= MOZ_BZ2_CFLAGS= MOZ_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 ${BZ2_LIBS}"
+if test "${BZ2_DIR}" -a -d "${BZ2_DIR}" -a "$MOZ_NATIVE_BZ2" = 1; then
+    MOZ_BZ2_CFLAGS="-I${BZ2_DIR}/include"
+    MOZ_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=
+    MOZ_NATIVE_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_valid, [MOZ_NATIVE_PNG=1 MOZ_PNG_LIBS="-lpng"],
+                 AC_MSG_ERROR([--with-system-png requested but no working libpng found]))
     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_MSG_ERROR([--with-system-png won't work because the system's libpng doesn't have APNG support]))
+fi
+if test "$MOZ_NATIVE_PNG" = 1; then
     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,
+                   MOZ_NATIVE_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}"
+if test "${PNG_DIR}" -a -d "${PNG_DIR}" -a "$MOZ_NATIVE_PNG" = 1; then
+    MOZ_PNG_CFLAGS="-I${PNG_DIR}/include"
+    MOZ_PNG_LIBS="-L${PNG_DIR}/lib ${MOZ_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
+    MOZ_NATIVE_HUNSPELL=1 )
+
+if test -n "$MOZ_NATIVE_HUNSPELL"; then
     PKG_CHECK_MODULES(MOZ_HUNSPELL, hunspell)
 fi
 
-AC_SUBST(SYSTEM_HUNSPELL)
+AC_SUBST(MOZ_NATIVE_HUNSPELL)
 
 dnl ========================================================
 dnl system libffi Support
 dnl ========================================================
 MOZ_ARG_ENABLE_BOOL(system-ffi,
 [  --enable-system-ffi       Use system libffi (located with pkgconfig)],
     MOZ_NATIVE_FFI=1 )
 
@@ -5877,26 +5869,26 @@ if test -z "$MOZ_CRASHREPORTER_ENABLE_PE
    MOZ_CRASHREPORTER_ENABLE_PERCENT=100
 fi
 AC_DEFINE_UNQUOTED(MOZ_CRASHREPORTER_ENABLE_PERCENT, $MOZ_CRASHREPORTER_ENABLE_PERCENT)
 
 dnl ========================================================
 dnl = libjpeg-turbo configuration
 dnl ========================================================
 MOZ_LIBJPEG_TURBO=
-if test -z "$SYSTEM_JPEG"; then
+if test -z "$MOZ_NATIVE_JPEG"; then
     MOZ_LIBJPEG_TURBO=1
 fi
 
 MOZ_ARG_DISABLE_BOOL(libjpeg_turbo,
 [ --disable-libjpeg-turbo  Disable optimized jpeg decoding routines],
     MOZ_LIBJPEG_TURBO=,
     MOZ_LIBJPEG_TURBO=1)
 
-if test "$SYSTEM_JPEG" = 1 -a "$MOZ_LIBJPEG_TURBO" = 1; then
+if test "$MOZ_NATIVE_JPEG" = 1 -a "$MOZ_LIBJPEG_TURBO" = 1; then
     AC_MSG_ERROR([cannot use --with-system-jpeg with --enable-libjpeg-turbo.])
 fi
 
 dnl Detect if we can use yasm to compile libjpeg-turbo's optimized assembly
 dnl files.
 
 if test -n "$MOZ_LIBJPEG_TURBO"; then
 
@@ -8486,31 +8478,22 @@ COMPILE_CFLAGS=`echo \
 	$_DEPEND_CFLAGS \
     $COMPILE_CFLAGS`
 
 COMPILE_CXXFLAGS=`echo \
     $_DEFINES_CXXFLAGS \
 	$_DEPEND_CFLAGS \
     $COMPILE_CXXFLAGS`
 
-AC_SUBST(SYSTEM_MAKEDEPEND)
+AC_SUBST(MOZ_NATIVE_MAKEDEPEND)
 AC_SUBST(SYSTEM_LIBXUL)
-AC_SUBST(SYSTEM_JPEG)
-AC_SUBST(SYSTEM_PNG)
-AC_SUBST(SYSTEM_ZLIB)
-AC_SUBST(SYSTEM_BZ2)
-
-AC_SUBST(JPEG_CFLAGS)
-AC_SUBST(JPEG_LIBS)
-AC_SUBST(ZLIB_CFLAGS)
-AC_SUBST(ZLIB_LIBS)
-AC_SUBST(BZ2_CFLAGS)
-AC_SUBST(BZ2_LIBS)
-AC_SUBST(PNG_CFLAGS)
-AC_SUBST(PNG_LIBS)
+AC_SUBST(MOZ_NATIVE_JPEG)
+AC_SUBST(MOZ_NATIVE_PNG)
+AC_SUBST(MOZ_NATIVE_ZLIB)
+AC_SUBST(MOZ_NATIVE_BZ2)
 
 AC_SUBST(MOZ_FLEXBOX)
 AC_SUBST(MOZ_JPEG_CFLAGS)
 AC_SUBST(MOZ_JPEG_LIBS)
 AC_SUBST(MOZ_ZLIB_CFLAGS)
 AC_SUBST(MOZ_ZLIB_LIBS)
 AC_SUBST(MOZ_BZ2_CFLAGS)
 AC_SUBST(MOZ_BZ2_LIBS)
@@ -8522,23 +8505,30 @@ AC_SUBST(NSPR_LIBS)
 AC_SUBST(MOZ_NATIVE_NSPR)
 
 AC_SUBST(NSS_CFLAGS)
 AC_SUBST(NSS_LIBS)
 AC_SUBST(NSS_DEP_LIBS)
 AC_SUBST(MOZ_NATIVE_NSS)
 AC_SUBST(NSS_DISABLE_DBM)
 
-AC_SUBST(CFLAGS)
-AC_SUBST(CXXFLAGS)
-AC_SUBST(CPPFLAGS)
-AC_SUBST(COMPILE_CFLAGS)
-AC_SUBST(COMPILE_CXXFLAGS)
-AC_SUBST(LDFLAGS)
-AC_SUBST(LIBS)
+OS_CFLAGS="$CFLAGS"
+OS_CXXFLAGS="$CXXFLAGS"
+OS_CPPFLAGS="$CPPFLAGS"
+OS_COMPILE_CFLAGS="$COMPILE_CFLAGS"
+OS_COMPILE_CXXFLAGS="$COMPILE_CXXFLAGS"
+OS_LDFLAGS="$LDFLAGS"
+OS_LIBS="$LIBS"
+AC_SUBST(OS_CFLAGS)
+AC_SUBST(OS_CXXFLAGS)
+AC_SUBST(OS_CPPFLAGS)
+AC_SUBST(OS_COMPILE_CFLAGS)
+AC_SUBST(OS_COMPILE_CXXFLAGS)
+AC_SUBST(OS_LDFLAGS)
+AC_SUBST(OS_LIBS)
 AC_SUBST(CROSS_COMPILE)
 AC_SUBST(WCHAR_CFLAGS)
 
 AC_SUBST(HOST_CC)
 AC_SUBST(HOST_CXX)
 AC_SUBST(HOST_CFLAGS)
 AC_SUBST(HOST_CXXFLAGS)
 AC_SUBST(HOST_LDFLAGS)
@@ -8830,18 +8820,18 @@ EOF
 dnl Probably shouldn't call this manually but we always want the output of DEFS
 rm -f confdefs.h.save
 mv confdefs.h confdefs.h.save
 $FIXED_EGREP -v "$_EGREP_PATTERN" confdefs.h.save > confdefs.h
 if test "$?" != 0; then
   AC_MSG_ERROR([Error outputting confdefs.h])
 fi
 AC_OUTPUT_MAKE_DEFS()
-MOZ_DEFINES=$DEFS
-AC_SUBST(MOZ_DEFINES)
+ACDEFINES=$DEFS
+AC_SUBST(ACDEFINES)
 rm -f confdefs.h
 mv confdefs.h.save confdefs.h
 
 dnl Create a virtualenv where we can install local Python packages
 AC_MSG_RESULT([Creating Python virtualenv])
 rm -rf _virtualenv
 mkdir -p _virtualenv
 MACOSX_DEPLOYMENT_TARGET= PYTHONDONTWRITEBYTECODE= $PYTHON $_topsrcdir/other-licenses/virtualenv/virtualenv.py --system-site-packages ./_virtualenv
--- a/js/src/config/autoconf.mk.in
+++ b/js/src/config/autoconf.mk.in
@@ -1,18 +1,15 @@
 #
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 # A netscape style .mk file for autoconf builds
 
-INCLUDED_AUTOCONF_MK = 1
-USE_AUTOCONF 	= 1
-MOZILLA_CLIENT	= 1
 target          = @target@
 ac_configure_args = @ac_configure_args@
 MOZILLA_VERSION = @MOZILLA_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@
@@ -22,25 +19,17 @@ MOZ_PKG_SPECIAL = @MOZ_PKG_SPECIAL@
 prefix		= @prefix@
 exec_prefix	= @exec_prefix@
 bindir		= @bindir@
 includedir	= @includedir@
 libdir		= @libdir@
 datadir		= @datadir@
 mandir		= @mandir@
 
-installdir	= $(libdir)/$(MOZ_APP_NAME)-$(MOZ_APP_VERSION)
-sdkdir		= $(libdir)/$(MOZ_APP_NAME)-devel-$(MOZ_APP_VERSION)
-
 TOP_DIST	= @TOP_DIST@
-ifneq (,$(filter /%,$(TOP_DIST)))
-DIST		= $(TOP_DIST)
-else
-DIST		= $(DEPTH)/$(TOP_DIST)
-endif
 
 MOZ_JS_LIBS		   = @MOZ_JS_LIBS@
 
 MOZ_SYNC_BUILD_FILES = @MOZ_SYNC_BUILD_FILES@
 
 MOZ_DEBUG	= @MOZ_DEBUG@
 MOZ_DEBUG_SYMBOLS = @MOZ_DEBUG_SYMBOLS@
 MOZ_DEBUG_ENABLE_DEFS		= @MOZ_DEBUG_ENABLE_DEFS@
@@ -62,18 +51,16 @@ DEHYDRA_PATH    = @DEHYDRA_PATH@
 
 NS_TRACE_MALLOC = @NS_TRACE_MALLOC@
 INCREMENTAL_LINKER = @INCREMENTAL_LINKER@
 MACOSX_DEPLOYMENT_TARGET = @MACOSX_DEPLOYMENT_TARGET@
 ENABLE_TESTS	= @ENABLE_TESTS@
 
 TAR=@TAR@
 
-RM = rm -f
-
 # 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@
 
@@ -89,27 +76,26 @@ MOZ_POST_DSO_LIB_COMMAND = @MOZ_POST_DSO
 MOZ_POST_PROGRAM_COMMAND = @MOZ_POST_PROGRAM_COMMAND@
 
 MOZ_BUILD_ROOT             = @MOZ_BUILD_ROOT@
 
 MOZ_NATIVE_NSPR = @MOZ_NATIVE_NSPR@
 
 CROSS_COMPILE   = @CROSS_COMPILE@
 
-OS_CPPFLAGS	= @CPPFLAGS@
-OS_CFLAGS	= $(OS_CPPFLAGS) @CFLAGS@
-OS_CXXFLAGS	= $(OS_CPPFLAGS) @CXXFLAGS@
-OS_LDFLAGS	= @LDFLAGS@
+OS_CPPFLAGS	= @OS_CPPFLAGS@
+OS_CFLAGS	= @OS_CFLAGS@
+OS_CXXFLAGS	= @OS_CXXFLAGS@
+OS_LDFLAGS	= @OS_LDFLAGS@
 
-OS_COMPILE_CFLAGS = $(OS_CPPFLAGS) @COMPILE_CFLAGS@
-OS_COMPILE_CXXFLAGS = $(OS_CPPFLAGS) @COMPILE_CXXFLAGS@
+OS_COMPILE_CFLAGS = @OS_COMPILE_CFLAGS@
+OS_COMPILE_CXXFLAGS = @OS_COMPILE_CXXFLAGS@
 
-OS_INCLUDES	= $(NSPR_CFLAGS)
-OS_LIBS		= @LIBS@
-ACDEFINES	= @MOZ_DEFINES@
+OS_LIBS		= @OS_LIBS@
+ACDEFINES	= @ACDEFINES@
 
 WARNINGS_AS_ERRORS = @WARNINGS_AS_ERRORS@
 FAIL_ON_WARNINGS = @FAIL_ON_WARNINGS@
 
 MOZ_OPTIMIZE	= @MOZ_OPTIMIZE@
 MOZ_FRAMEPTR_FLAGS = @MOZ_FRAMEPTR_FLAGS@
 MOZ_OPTIMIZE_FLAGS = @MOZ_OPTIMIZE_FLAGS@
 MOZ_PGO_OPTIMIZE_FLAGS = @MOZ_PGO_OPTIMIZE_FLAGS@
@@ -137,20 +123,17 @@ MC		= @MC@
 WINDRES		= @WINDRES@
 IMPLIB		= @IMPLIB@
 FILTER		= @FILTER@
 BIN_FLAGS	= @BIN_FLAGS@
 _MSC_VER	= @_MSC_VER@
 
 DLL_PREFIX	= @DLL_PREFIX@
 LIB_PREFIX	= @LIB_PREFIX@
-# We do magic with OBJ_SUFFIX in config.mk, the following ensures we don't
-# manually use it before config.mk inclusion
-OBJ_SUFFIX	= $(error config/config.mk needs to be included before using OBJ_SUFFIX)
-_OBJ_SUFFIX	= @OBJ_SUFFIX@
+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@
 LIBS_DESC_SUFFIX = @LIBS_DESC_SUFFIX@
 USE_N32		= @USE_N32@
 HAVE_64BIT_OS	= @HAVE_64BIT_OS@
@@ -196,17 +179,17 @@ TARGET_XPCOM_ABI = @TARGET_XPCOM_ABI@
 
 AUTOCONF	= @AUTOCONF@
 PERL		= @PERL@
 PYTHON		= @PYTHON@
 RANLIB		= @RANLIB@
 XARGS		= @XARGS@
 STRIP		= @STRIP@
 DOXYGEN		= @DOXYGEN@
-PBBUILD_BIN	= @PBBUILD@
+PBBUILD_BIN	= @PBBUILD_BIN@
 SDP		= @SDP@
 NSINSTALL_BIN	= @NSINSTALL_BIN@
 
 NSPR_CONFIG	= @NSPR_CONFIG@
 NSPR_CFLAGS	= @NSPR_CFLAGS@
 NSPR_LIBS	= @NSPR_LIBS@
 
 MOZ_NATIVE_FFI	= @MOZ_NATIVE_FFI@
@@ -231,22 +214,19 @@ 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@
 
-MOZ_TOOLKIT_REGISTRY_CFLAGS = \
-	$(TK_CFLAGS)
+MOZ_NATIVE_MAKEDEPEND	= @MOZ_NATIVE_MAKEDEPEND@
 
-MOZ_NATIVE_MAKEDEPEND	= @SYSTEM_MAKEDEPEND@
-
-export CL_INCLUDES_PREFIX = @CL_INCLUDES_PREFIX@
+CL_INCLUDES_PREFIX = @CL_INCLUDES_PREFIX@
 
 MOZ_AUTO_DEPS	= @MOZ_AUTO_DEPS@
 COMPILER_DEPEND = @COMPILER_DEPEND@
 MDDEPDIR        := @MDDEPDIR@
 CC_WRAPPER = @CC_WRAPPER@
 CXX_WRAPPER = @CXX_WRAPPER@
 
 MOZ_DEMANGLE_SYMBOLS = @MOZ_DEMANGLE_SYMBOLS@
@@ -299,20 +279,9 @@ HAVE_ARM_SIMD= @HAVE_ARM_SIMD@
 
 JS_SHARED_LIBRARY = @JS_SHARED_LIBRARY@
 HAVE_LINUX_PERF_EVENT_H = @HAVE_LINUX_PERF_EVENT_H@
 
 MOZ_METRO	= @MOZ_METRO@
 
 MOZ_ASAN = @MOZ_ASAN@
 
-# We only want to do the pymake sanity on Windows, other os's can cope
-ifeq ($(HOST_OS_ARCH),WINNT)
-# Ensure invariants between GNU Make and pymake
-# Checked here since we want the sane error in a file that
-# actually can be found regardless of path-style.
-ifeq (_:,$(.PYMAKE)_$(findstring :,$(srcdir)))
-$(error Windows-style srcdir being used with GNU make. Did you mean to run $(topsrcdir)/build/pymake/make.py instead? [see-also: https://developer.mozilla.org/en/Gmake_vs._Pymake])
-endif
-ifeq (1_a,$(.PYMAKE)_$(firstword a$(subst /, ,$(srcdir))))
-$(error MSYS-style srcdir being used with Pymake. Did you mean to run GNU Make instead? [see-also: https://developer.mozilla.org/en/Gmake_vs._Pymake])
-endif
-endif # WINNT
+include $(topsrcdir)/config/baseconfig.mk
new file mode 100644
--- /dev/null
+++ b/js/src/config/baseconfig.mk
@@ -0,0 +1,28 @@
+INCLUDED_AUTOCONF_MK = 1
+
+installdir = $(libdir)/$(MOZ_APP_NAME)-$(MOZ_APP_VERSION)
+sdkdir = $(libdir)/$(MOZ_APP_NAME)-devel-$(MOZ_APP_VERSION)
+
+ifneq (,$(filter /%,$(TOP_DIST)))
+DIST = $(TOP_DIST)
+else
+DIST = $(DEPTH)/$(TOP_DIST)
+endif
+
+# We do magic with OBJ_SUFFIX in config.mk, the following ensures we don't
+# manually use it before config.mk inclusion
+_OBJ_SUFFIX := $(OBJ_SUFFIX)
+OBJ_SUFFIX = $(error config/config.mk needs to be included before using OBJ_SUFFIX)
+
+# We only want to do the pymake sanity on Windows, other os's can cope
+ifeq ($(HOST_OS_ARCH),WINNT)
+# Ensure invariants between GNU Make and pymake
+# Checked here since we want the sane error in a file that
+# actually can be found regardless of path-style.
+ifeq (_:,$(.PYMAKE)_$(findstring :,$(srcdir)))
+$(error Windows-style srcdir being used with GNU make. Did you mean to run $(topsrcdir)/build/pymake/make.py instead? [see-also:     https://developer.mozilla.org/en/Gmake_vs._Pymake])
+endif
+ifeq (1_a,$(.PYMAKE)_$(firstword a$(subst /, ,$(srcdir))))
+$(error MSYS-style srcdir being used with Pymake. Did you mean to run GNU Make instead? [see-also: https://developer.mozilla.org/    en/Gmake_vs._Pymake])
+endif
+endif # WINNT
--- a/js/src/config/check-sync-exceptions
+++ b/js/src/config/check-sync-exceptions
@@ -1,12 +1,13 @@
 Makefile.in
 Makefile
 autoconf.mk.in
 autoconf.mk
+baseconfig.mk
 check-sync-dirs.py
 static-checking-config.mk
 nsinstall
 nsinstall.exe
 host_nsinstall.o
 host_pathsub.o
 
 # This is a copy of nspr's config/make-system-wrappers.pl.
--- a/js/src/config/config.mk
+++ b/js/src/config/config.mk
@@ -51,16 +51,18 @@ check-variable = $(if $(filter-out 0 1,$
 core_abspath = $(if $(findstring :,$(1)),$(1),$(if $(filter /%,$(1)),$(1),$(CURDIR)/$(1)))
 core_realpath = $(if $(realpath $(1)),$(realpath $(1)),$(call core_abspath,$(1)))
 
 nullstr :=
 space :=$(nullstr) # EOL
 
 core_winabspath = $(firstword $(subst /, ,$(call core_abspath,$(1)))):$(subst $(space),,$(patsubst %,\\%,$(wordlist 2,$(words $(subst /, ,$(call core_abspath,$(1)))), $(strip $(subst /, ,$(call core_abspath,$(1)))))))
 
+RM = rm -f
+
 # LIBXUL_DIST is not defined under js/src, thus we make it mean DIST there.
 LIBXUL_DIST ?= $(DIST)
 
 # FINAL_TARGET specifies the location into which we copy end-user-shipped
 # build products (typelibs, components, chrome).
 #
 # If XPI_NAME is set, the files will be shipped to $(DIST)/xpi-stage/$(XPI_NAME)
 # If DIST_SUBDIR is set, the files will be shipped to $(DIST)/$(DIST_SUBDIR)
@@ -365,29 +367,31 @@ MY_RULES	:= $(DEPTH)/config/myrules.mk
 CCC = $(CXX)
 XPIDL_LINK = $(PYTHON) $(LIBXUL_DIST)/sdk/bin/xpt.py link
 
 # Java macros
 JAVA_GEN_DIR  = _javagen
 JAVA_DIST_DIR = $(DEPTH)/$(JAVA_GEN_DIR)
 JAVA_IFACES_PKG_NAME = org/mozilla/interfaces
 
+OS_INCLUDES += $(NSPR_CFLAGS) $(NSS_CFLAGS) $(MOZ_JPEG_CFLAGS) $(MOZ_PNG_CFLAGS) $(MOZ_ZLIB_CFLAGS)
+
 INCLUDES = \
   $(LOCAL_INCLUDES) \
   -I$(srcdir) \
   -I. \
   -I$(DIST)/include \
   $(if $(LIBXUL_SDK),-I$(LIBXUL_SDK)/include) \
   $(OS_INCLUDES) \
   $(NULL)
 
 include $(topsrcdir)/config/static-checking-config.mk
 
-CFLAGS		= $(OS_CFLAGS)
-CXXFLAGS	= $(OS_CXXFLAGS)
+CFLAGS		= $(OS_CPPFLAGS) $(OS_CFLAGS)
+CXXFLAGS	= $(OS_CPPFLAGS) $(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
@@ -484,18 +488,18 @@ HOST_CMMFLAGS += -fobjc-exceptions
 OS_COMPILE_CMFLAGS += -fobjc-exceptions
 OS_COMPILE_CMMFLAGS += -fobjc-exceptions
 ifeq ($(MOZ_WIDGET_TOOLKIT),uikit)
 OS_COMPILE_CMFLAGS += -fobjc-abi-version=2 -fobjc-legacy-dispatch
 OS_COMPILE_CMMFLAGS += -fobjc-abi-version=2 -fobjc-legacy-dispatch
 endif
 endif
 
-COMPILE_CFLAGS	= $(VISIBILITY_FLAGS) $(DEFINES) $(INCLUDES) $(DSO_CFLAGS) $(DSO_PIC_CFLAGS) $(CFLAGS) $(RTL_FLAGS) $(OS_COMPILE_CFLAGS)
-COMPILE_CXXFLAGS = $(STL_FLAGS) $(VISIBILITY_FLAGS) $(DEFINES) $(INCLUDES) $(DSO_CFLAGS) $(DSO_PIC_CFLAGS) $(CXXFLAGS) $(RTL_FLAGS) $(OS_COMPILE_CXXFLAGS)
+COMPILE_CFLAGS	= $(VISIBILITY_FLAGS) $(DEFINES) $(INCLUDES) $(DSO_CFLAGS) $(DSO_PIC_CFLAGS) $(CFLAGS) $(RTL_FLAGS) $(OS_CPPFLAGS) $(OS_COMPILE_CFLAGS)
+COMPILE_CXXFLAGS = $(STL_FLAGS) $(VISIBILITY_FLAGS) $(DEFINES) $(INCLUDES) $(DSO_CFLAGS) $(DSO_PIC_CFLAGS) $(CXXFLAGS) $(RTL_FLAGS) $(OS_CPPFLAGS) $(OS_COMPILE_CXXFLAGS)
 COMPILE_CMFLAGS = $(OS_COMPILE_CMFLAGS)
 COMPILE_CMMFLAGS = $(OS_COMPILE_CMMFLAGS)
 
 ifndef CROSS_COMPILE
 HOST_CFLAGS += $(RTL_FLAGS)
 endif
 
 #
@@ -788,8 +792,10 @@ EXPAND_LIBNAME = $(foreach lib,$(1),$(LI
 endif
 EXPAND_LIBNAME_PATH = $(foreach lib,$(1),$(2)/$(LIB_PREFIX)$(lib).$(LIB_SUFFIX))
 EXPAND_MOZLIBNAME = $(foreach lib,$(1),$(DIST)/lib/$(LIB_PREFIX)$(lib).$(LIB_SUFFIX))
 
 # Include internal ply only if needed
 ifndef MOZ_SYSTEM_PLY
 PLY_INCLUDE = -I$(topsrcdir)/other-licenses/ply
 endif
+
+export CL_INCLUDES_PREFIX
--- a/js/src/configure.in
+++ b/js/src/configure.in
@@ -795,17 +795,17 @@ fi
 
 if test -z "$COMPILE_ENVIRONMENT"; then
     NSINSTALL_BIN='$(PYTHON) $(topsrcdir)/config/nsinstall.py'
 fi
 AC_SUBST(NSINSTALL_BIN)
 
 MOZ_PATH_PROG(DOXYGEN, doxygen, :)
 MOZ_PATH_PROG(AUTOCONF, autoconf, :)
-MOZ_PATH_PROG(SYSTEM_MAKEDEPEND, makedepend)
+MOZ_PATH_PROG(MOZ_NATIVE_MAKEDEPEND, makedepend)
 MOZ_PATH_PROG(XARGS, xargs)
 if test -z "$XARGS" -o "$XARGS" = ":"; then
     AC_MSG_ERROR([xargs not found in \$PATH .])
 fi
 
 if test "$COMPILE_ENVIRONMENT"; then
 
 dnl ========================================================
@@ -833,17 +833,17 @@ darwin*)
 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.
-    MOZ_PATH_PROGS(PBBUILD, pbbuild xcodebuild pbxbuild)
+    MOZ_PATH_PROGS(PBBUILD_BIN, pbbuild xcodebuild pbxbuild)
 
     dnl sdp was formerly in /Developer/Tools.  As of Mac OS X 10.4 (Darwin 8),
     dnl it has moved into /usr/bin.
     MOZ_PATH_PROG(SDP, sdp, :, [$PATH:/usr/bin:/Developer/Tools])
     ;;
 esac
 
 AC_SUBST(GCC_VERSION)
@@ -1776,17 +1776,17 @@ ia64*-hpux*)
        MKCSHLIB='$(CC) $(CFLAGS) $(DSO_LDOPTS) -o $@'
        CXXFLAGS="$CXXFLAGS -Wc,-ansi_for_scope,on"
     else
        DSO_LDOPTS='-b -E'
        MKSHLIB='$(LD) $(DSO_LDOPTS) -o $@'
        MKCSHLIB='$(LD) $(DSO_LDOPTS) -o $@'
     fi
     MOZ_FIX_LINK_PATHS=
-    SYSTEM_MAKEDEPEND=
+    MOZ_NATIVE_MAKEDEPEND=
     AC_DEFINE(NSCAP_DISABLE_DEBUG_PTR_TYPES)
     AC_DEFINE(_LARGEFILE64_SOURCE)
     ;;
 
 *-hpux*)
     DLL_SUFFIX=".sl"
     if test ! "$GNU_CC"; then
     	DSO_LDOPTS='-b -Wl,+s'
@@ -1856,17 +1856,17 @@ ia64*-hpux*)
 *-mingw*)
     DSO_CFLAGS=
     DSO_PIC_CFLAGS=
     DLL_SUFFIX=.dll
     RC=rc.exe
     MC=mc.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=
+    MOZ_NATIVE_MAKEDEPEND=
     if test -n "$GNU_CC"; then
         CC="$CC -mwindows"
         CXX="$CXX -mwindows"
         CPP="$CPP -mwindows"
         CFLAGS="$CFLAGS -mms-bitfields"
         CXXFLAGS="$CXXFLAGS -mms-bitfields"
         DSO_LDOPTS='-shared'
         MKSHLIB='$(CXX) $(DSO_LDOPTS) -o $@'
@@ -2135,17 +2135,17 @@ ia64*-hpux*)
 *-solaris*)
     AC_DEFINE(SOLARIS)
     TARGET_NSPR_MDCPUCFG='\"md/_solaris.cfg\"'
     if test -z "$CROSS_COMPILE" && pkginfo -q SUNWpr && pkginfo -q SUNWprd; then
        NO_NSPR_CONFIG_SYSTEM_LDFLAGS="-L/usr/lib/mps -R/usr/lib/mps -lnspr4"
        NO_NSPR_CONFIG_SYSTEM_CFLAGS="-I/usr/include/mps"
        NO_NSPR_CONFIG_SYSTEM_VERSION=["`pkgparam SUNWpr SUNW_PRODVERS | sed -e 's/^[1-9][0-9]*\.[0-9][0-9]*$/&.0/'`"]
     fi
-    SYSTEM_MAKEDEPEND=
+    MOZ_NATIVE_MAKEDEPEND=
     MOZ_FIX_LINK_PATHS=
     # $ORIGIN/.. is for shared libraries under components/ to locate shared
     # libraries one level up (e.g. libnspr4.so)
     if test "$SOLARIS_SUNPRO_CC"; then
        LDFLAGS="$LDFLAGS -z ignore -R '\$\$ORIGIN:\$\$ORIGIN/..' -z lazyload -z combreloc -z muldefs"
        LIBS="-lCrun -lCstd -lc $LIBS"
        AC_DEFINE(NSCAP_DISABLE_DEBUG_PTR_TYPES)
        CFLAGS="$CFLAGS -xlibmieee -xstrconst -xbuiltin=%all -D__FUNCTION__=__func__"
@@ -4515,19 +4515,17 @@ AC_SUBST(USE_DEPENDENT_LIBS)
 AC_SUBST(MOZ_BUILD_ROOT)
 AC_SUBST(MOZ_OS2_TOOLS)
 
 AC_SUBST(MOZ_POST_DSO_LIB_COMMAND)
 AC_SUBST(MOZ_POST_PROGRAM_COMMAND)
 
 AC_SUBST(MOZ_APP_NAME)
 AC_SUBST(MOZ_APP_DISPLAYNAME)
-AC_SUBST(MOZ_APP_UA_NAME)
 AC_SUBST(MOZ_APP_VERSION)
-AC_SUBST(FIREFOX_VERSION)
 
 AC_SUBST(MOZ_PKG_SPECIAL)
 
 AC_SUBST(MOZILLA_OFFICIAL)
 
 dnl win32 options
 AC_SUBST(MOZ_MAPINFO)
 AC_SUBST(MOZ_BROWSE_INFO)
@@ -4548,29 +4546,36 @@ COMPILE_CFLAGS=`echo \
 	$_DEPEND_CFLAGS \
     $COMPILE_CFLAGS`
 
 COMPILE_CXXFLAGS=`echo \
     $_DEFINES_CXXFLAGS \
 	$_DEPEND_CFLAGS \
     $COMPILE_CXXFLAGS`
 
-AC_SUBST(SYSTEM_MAKEDEPEND)
+AC_SUBST(MOZ_NATIVE_MAKEDEPEND)
 
 AC_SUBST(NSPR_CFLAGS)
 AC_SUBST(NSPR_LIBS)
 AC_SUBST(MOZ_NATIVE_NSPR)
 
-AC_SUBST(CFLAGS)
-AC_SUBST(CXXFLAGS)
-AC_SUBST(CPPFLAGS)
-AC_SUBST(COMPILE_CFLAGS)
-AC_SUBST(COMPILE_CXXFLAGS)
-AC_SUBST(LDFLAGS)
-AC_SUBST(LIBS)
+OS_CFLAGS="$CFLAGS"
+OS_CXXFLAGS="$CXXFLAGS"
+OS_CPPFLAGS="$CPPFLAGS"
+OS_COMPILE_CFLAGS="$COMPILE_CFLAGS"
+OS_COMPILE_CXXFLAGS="$COMPILE_CXXFLAGS"
+OS_LDFLAGS="$LDFLAGS"
+OS_LIBS="$LIBS"
+AC_SUBST(OS_CFLAGS)
+AC_SUBST(OS_CXXFLAGS)
+AC_SUBST(OS_CPPFLAGS)
+AC_SUBST(OS_COMPILE_CFLAGS)
+AC_SUBST(OS_COMPILE_CXXFLAGS)
+AC_SUBST(OS_LDFLAGS)
+AC_SUBST(OS_LIBS)
 AC_SUBST(CROSS_COMPILE)
 AC_SUBST(MOZ_METRO)
 
 AC_SUBST(HOST_CC)
 AC_SUBST(HOST_CXX)
 AC_SUBST(HOST_CFLAGS)
 AC_SUBST(HOST_CXXFLAGS)
 AC_SUBST(HOST_LDFLAGS)
@@ -4771,18 +4776,18 @@ EOF
 dnl Probably shouldn't call this manually but we always want the output of DEFS
 rm -f confdefs.h.save
 mv confdefs.h confdefs.h.save
 egrep -v "$_EGREP_PATTERN" confdefs.h.save > confdefs.h
 if test "$?" != 0; then
   AC_MSG_ERROR([Error outputting confdefs.h])
 fi
 AC_OUTPUT_MAKE_DEFS()
-MOZ_DEFINES=$DEFS
-AC_SUBST(MOZ_DEFINES)
+ACDEFINES=$DEFS
+AC_SUBST(ACDEFINES)
 rm -f confdefs.h
 mv confdefs.h.save confdefs.h
 
 MAKEFILES="
   Makefile
   shell/Makefile
   config/Makefile
   config/autoconf.mk
--- a/layout/media/Makefile.in
+++ b/layout/media/Makefile.in
@@ -113,21 +113,17 @@ ifdef MOZ_ENABLE_SKIA
 SHARED_LIBRARY_LIBS += $(MOZ_SKIA_LIBS)
 endif
 
 ifeq (WINNT,$(OS_TARGET))
 EXTRA_DSO_LDOPTS = $(MOZALLOC_LIB) $(NSPR_LIBS)
 OS_LIBS += $(call EXPAND_LIBNAME,usp10 ole32)
 
 # OTS uses uncompress2() from libz, so we need to link with this
-ifdef MOZ_NATIVE_ZLIB
-EXTRA_DSO_LDOPTS += $(ZLIB_LIBS)
-else
 EXTRA_DSO_LDOPTS += $(MOZ_ZLIB_LIBS)
-endif
 
 DEFFILE = symbols.def
 endif
 
 include $(topsrcdir)/config/rules.mk
 
 ifeq (WINNT,$(OS_TARGET))
 symbols.def: symbols.def.in
--- a/mozglue/build/Makefile.in
+++ b/mozglue/build/Makefile.in
@@ -62,17 +62,17 @@ ifeq (Android,$(OS_TARGET))
 # To properly wrap jemalloc's pthread_atfork call.
 EXTRA_DSO_LDOPTS += -Wl,--wrap=pthread_atfork
 CPPSRCS += BionicGlue.cpp
 SHARED_LIBRARY_LIBS += $(call EXPAND_LIBNAME_PATH,android,$(DEPTH)/other-licenses/android)
 endif
 
 ifeq (android, $(MOZ_WIDGET_TOOLKIT))
 # Add Android specific code
-EXTRA_DSO_LDOPTS += $(ZLIB_LIBS)
+EXTRA_DSO_LDOPTS += $(MOZ_ZLIB_LIBS)
 SHARED_LIBRARY_LIBS += $(call EXPAND_LIBNAME_PATH,android,../android)
 endif
 
 ifdef MOZ_LINKER
 # Add custom dynamic linker
 SHARED_LIBRARY_LIBS += $(call EXPAND_LIBNAME_PATH,linker,../linker)
 
 ifeq (arm, $(TARGET_CPU))
--- a/mozglue/tests/Makefile.in
+++ b/mozglue/tests/Makefile.in
@@ -19,17 +19,17 @@ NO_DIST_INSTALL = 1
 STL_FLAGS =
 
 LOCAL_INCLUDES += -I$(srcdir)/../linker
 # Only link against the linker, not mozglue
 MOZ_GLUE_PROGRAM_LDFLAGS =
 MOZ_GLUE_LDFLAGS =
 LIBS += $(call EXPAND_LIBNAME_PATH,linker,../linker)
 
-EXTRA_LIBS = $(ZLIB_LIBS)
+EXTRA_LIBS = $(MOZ_ZLIB_LIBS)
 endif
 
 include $(topsrcdir)/config/rules.mk
 
 ifdef MOZ_LINKER
 check::
 	@$(EXIT_ON_ERROR) ./TestZip$(BIN_SUFFIX) $(srcdir)
 endif
--- a/other-licenses/bsdiff/Makefile.in
+++ b/other-licenses/bsdiff/Makefile.in
@@ -30,22 +30,22 @@ VPATH     = @srcdir@
 include $(DEPTH)/config/autoconf.mk
 
 # This program is output to dist/host/bin because it is only needed by the
 # build system and is not intended to be included in Mozilla distributions.
 HOST_PROGRAM = mbsdiff$(BIN_SUFFIX)
 HOST_CSRCS = bsdiff.c
 
 ifdef MOZ_NATIVE_BZ2
-HOST_LIBS += $(BZ2_LIBS)
+HOST_LIBS += $(MOZ_BZ2_LIBS)
 else
 HOST_LIBS += $(DIST)/host/lib/$(LIB_PREFIX)hostbz2.$(LIB_SUFFIX)
 endif
 
 ifeq ($(HOST_OS_ARCH),WINNT)
 HOST_EXTRA_LIBS += $(call EXPAND_LIBNAME,Ws2_32)
 endif
 
 LOCAL_INCLUDES += -I$(topsrcdir)/toolkit/mozapps/update/updater
 
 include $(topsrcdir)/config/rules.mk
 
-CXXFLAGS += $(BZ2_CFLAGS)
+CXXFLAGS += $(MOZ_BZ2_CFLAGS)
--- a/rdf/tests/rdfcat/Makefile.in
+++ b/rdf/tests/rdfcat/Makefile.in
@@ -22,9 +22,9 @@ LIBS		= \
 		$(NULL)
 
 ifeq ($(OS_ARCH),WINNT)
 MAPFILE=rdfcat.map
 endif
 
 include $(topsrcdir)/config/rules.mk
 
-CXXFLAGS += $(MOZ_TOOLKIT_REGISTRY_CFLAGS)
+CXXFLAGS += $(TK_CFLAGS)
--- a/rdf/tests/triplescat/Makefile.in
+++ b/rdf/tests/triplescat/Makefile.in
@@ -22,9 +22,9 @@ LIBS		= \
 		$(NULL)
 
 ifeq ($(OS_ARCH),WINNT)
 MAPFILE=triplescat.map
 endif
 
 include $(topsrcdir)/config/rules.mk
 
-CXXFLAGS += $(MOZ_TOOLKIT_REGISTRY_CFLAGS)
+CXXFLAGS += $(TK_CFLAGS)
--- a/toolkit/library/Makefile.in
+++ b/toolkit/library/Makefile.in
@@ -343,28 +343,24 @@ EXTRA_DSO_LDOPTS += \
   $(MOZ_JS_LIBS) \
   $(NSS_LIBS) \
   $(MOZ_CAIRO_OSLIBS) \
   $(MOZ_APP_EXTRA_LIBS) \
   $(SQLITE_LIBS) \
   $(NULL)
 
 ifdef MOZ_NATIVE_JPEG
-EXTRA_DSO_LDOPTS += $(JPEG_LIBS)
+EXTRA_DSO_LDOPTS += $(MOZ_JPEG_LIBS)
 endif
 
 ifdef MOZ_NATIVE_PNG
-EXTRA_DSO_LDOPTS += $(PNG_LIBS)
+EXTRA_DSO_LDOPTS += $(MOZ_PNG_LIBS)
 endif
 
-ifdef MOZ_NATIVE_ZLIB
-EXTRA_DSO_LDOPTS += $(ZLIB_LIBS)
-else
 EXTRA_DSO_LDOPTS += $(MOZ_ZLIB_LIBS)
-endif
 
 ifdef MOZ_NATIVE_HUNSPELL
 EXTRA_DSO_LDOPTS += $(MOZ_HUNSPELL_LIBS)
 endif
 
 ifdef MOZ_NATIVE_LIBEVENT
 EXTRA_DSO_LDOPTS += $(MOZ_LIBEVENT_LIBS)
 endif
--- a/toolkit/mozapps/update/updater/Makefile.in
+++ b/toolkit/mozapps/update/updater/Makefile.in
@@ -30,17 +30,17 @@ MOZ_GLUE_PROGRAM_LDFLAGS =
 
 LOCAL_INCLUDES += \
   -I$(srcdir)/../common \
   $(NULL)
 
 LIBS += \
   ../common/$(LIB_PREFIX)updatecommon.$(LIB_SUFFIX) \
   $(DEPTH)/modules/libmar/src/$(LIB_PREFIX)mar.$(LIB_SUFFIX) \
-  $(BZ2_LIBS) \
+  $(MOZ_BZ2_LIBS) \
   $(NULL)
 
 ifeq ($(OS_ARCH),WINNT)
 LIBS += $(DEPTH)/modules/libmar/verify/$(LIB_PREFIX)verifymar.$(LIB_SUFFIX)
 USE_STATIC_LIBS = 1
 HAVE_PROGRESSUI = 1
 RCINCLUDE = updater.rc
 CPPSRCS += \
@@ -124,17 +124,17 @@ ifeq (,$(filter-out WINNT,$(OS_ARCH)))
 LOCAL_INCLUDES += -I$(topsrcdir)/toolkit/xre
 endif
 
 ifeq ($(OS_ARCH),WINNT)
 EXTRA_LIBS += $(call EXPAND_LIBNAME,crypt32)
 EXTRA_LIBS += $(call EXPAND_LIBNAME,advapi32)
 endif
 
-CXXFLAGS += $(BZ2_CFLAGS)
+CXXFLAGS += $(MOZ_BZ2_CFLAGS)
 
 ifneq (,$(filter beta release esr,$(MOZ_UPDATE_CHANNEL)))
 RCFLAGS += -DMAR_SIGNING_RELEASE_BETA=1
 else
 ifneq (,$(filter nightly aurora nightly-elm nightly-profiling nightly-oak,$(MOZ_UPDATE_CHANNEL)))
 RCFLAGS += -DMAR_SIGNING_AURORA_NIGHTLY=1
 endif
 endif
--- a/toolkit/toolkit-makefiles.sh
+++ b/toolkit/toolkit-makefiles.sh
@@ -1324,17 +1324,17 @@ if [ "$MOZ_TOOLKIT_SEARCH" ]; then
 fi
 
 if [ "$MOZ_UPDATER" ]; then
   add_makefiles "
     modules/libmar/Makefile
     modules/libmar/src/Makefile
     modules/libmar/tool/Makefile
   "
-  if [ ! "$SYSTEM_BZ2" ]; then
+  if [ ! "$MOZ_NATIVE_BZ2" ]; then
     add_makefiles "
       modules/libbz2/Makefile
       modules/libbz2/src/Makefile
     "
   fi
   if [ "$OS_TARGET" != "Android" ]; then
     add_makefiles "
       toolkit/mozapps/update/updater/Makefile
@@ -1459,37 +1459,37 @@ if [ "$MOZ_PSM" ]; then
     security/manager/pki/Makefile
     security/manager/pki/resources/Makefile
     security/manager/pki/src/Makefile
     security/manager/pki/public/Makefile
     security/manager/locales/Makefile
   "
 fi
 
-if [ ! "$SYSTEM_JPEG" ]; then
+if [ ! "$MOZ_NATIVE_JPEG" ]; then
   add_makefiles "
     media/libjpeg/Makefile
     media/libjpeg/simd/Makefile
   "
 fi
 
-if [ ! "$SYSTEM_ZLIB" ]; then
+if [ ! "$MOZ_NATIVE_ZLIB" ]; then
   add_makefiles "
     modules/zlib/Makefile
     modules/zlib/src/Makefile
   "
 fi
 
 if [ "$MOZ_UPDATE_PACKAGING" ]; then
   add_makefiles "
     tools/update-packaging/Makefile
   "
 fi
 
-if [ ! "$SYSTEM_PNG" ]; then
+if [ ! "$MOZ_NATIVE_PNG" ]; then
   add_makefiles "
     media/libpng/Makefile
   "
 fi
 
 if [ "$MOZ_JPROF" ]; then
   add_makefiles "
     tools/jprof/Makefile