Bug 969164 - Traverse js/src moz.builds from top-level configure. r=gps
authorMike Hommey <mh+mozilla@glandium.org>
Tue, 11 Feb 2014 10:37:47 +0900
changeset 168013 2f0f52f627d71c2676d8f7c34830e0d03d6fa3e6
parent 168012 06f5f22f1bb9d738849fc16bf99108ed641a2e9e
child 168014 4e3b435b7d3950b9b366d5376f50f3d0d91dc85a
push id4990
push userryanvm@gmail.com
push dateTue, 11 Feb 2014 13:44:23 +0000
treeherderfx-team@937e5e0668ed [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgps
bugs969164
milestone30.0a1
Bug 969164 - Traverse js/src moz.builds from top-level configure. r=gps Before, we would run configure in both top-level and js/src, and both configures would traverse their own set of moz.builds, without actual knowledge about the other. With this change, both configures still run, but only top-level traverses moz.build files, and uses js/src's config.status when traversing its moz.build files. This allows a better sharing of information between both build systems and the removal of many hacks. This also moves running libffi and icu configure to top-level. Standalone js builds still have their own configure doing moz.build traversal, as before.
CLOBBER
Makefile.in
build/autoconf/config.status.m4
build/autoconf/ffi.m4
build/autoconf/icu.m4
config/autoconf-js.mk.in
config/emptyvars-js.mk.in
config/js/js.mozbuild
config/static-checking-config.mk
configure.in
js/src/configure.in
js/src/moz.build
moz.build
python/mozbuild/mozbuild/backend/recursivemake.py
python/mozbuild/mozbuild/frontend/reader.py
testing/testsuite-targets.mk
toolkit/toolkit.mozbuild
--- a/CLOBBER
+++ b/CLOBBER
@@ -17,9 +17,9 @@
 #
 # Modifying this file will now automatically clobber the buildbot machines \o/
 #
 
 # Are you updating CLOBBER because you think it's needed for your WebIDL
 # changes to stick? As of bug 928195, this shouldn't be necessary! Please
 # don't change CLOBBER for WebIDL changes any more.
 
-Bug 964200 - Touching webidl files in this bug doesn't work without a clobber. Tried landing already and had to back out.
+Bug 969164 changes the directory layout under js/src during gecko builds, and that causes a build failure on incremental builds because of the js shell trying to replace a directory with the same name.
--- a/Makefile.in
+++ b/Makefile.in
@@ -18,68 +18,64 @@ export TOPLEVEL_BUILD := 1
 default::
 
 ifdef MOZ_BUILD_APP
 include $(topsrcdir)/$(MOZ_BUILD_APP)/build.mk
 endif
 
 include $(topsrcdir)/config/config.mk
 
-ifndef LIBXUL_SDK
-ifdef COMPILE_ENVIRONMENT
-ifndef BUILDING_JS
-BUILD_JS = 1
-endif
-endif
-endif
-
 GARBAGE_DIRS += dist _javagen _profile staticlib
 DIST_GARBAGE = config.cache config.log config.status* config-defs.h \
    config/autoconf.mk \
    mozilla-config.h \
    netwerk/necko-config.h xpcom/xpcom-config.h xpcom/xpcom-private.h \
    .mozconfig.mk
 
-ifdef BUILDING_JS
+ifdef JS_STANDALONE
 configure_dir = $(topsrcdir)/js/src
 else
 configure_dir = $(topsrcdir)
 endif
 
 ifndef MOZ_PROFILE_USE
 # We need to explicitly put backend.RecursiveMakeBackend here
 # otherwise the rule in rules.mk doesn't run early enough.
 libs binaries export tools:: CLOBBER $(configure_dir)/configure config.status backend.RecursiveMakeBackend
-ifdef BUILD_JS
-libs binaries export tools:: js-config-status
+ifndef JS_STANDALONE
+libs binaries export tools:: $(topsrcdir)/js/src/configure js/src/config.status
 endif
 endif
 
 ifdef BUILDING_JS
 .PHONY: CLOBBER
 CLOBBER:
 else
 CLOBBER: $(topsrcdir)/CLOBBER
 	@echo 'STOP!  The CLOBBER file has changed.'
 	@echo 'Please run the build through a sanctioned build wrapper, such as'
 	@echo '"mach build" or client.mk.'
 	@exit 1
 endif
 
-$(configure_dir)/configure: $(configure_dir)/configure.in
-	@echo 'STOP!  configure.in has changed, and your configure is out of date.'
+$(topsrcdir)/configure: $(topsrcdir)/configure.in
+$(topsrcdir)/js/src/configure: $(topsrcdir)/js/src/configure.in
+$(topsrcdir)/configure $(topsrcdir)/js/src/configure:
+	@echo 'STOP!  $^ has changed, and your configure is out of date.'
 	@echo 'Please rerun autoconf and re-configure your build directory.'
-	@echo 'To ignore this message, touch "configure" in the source directory,'
+	@echo 'To ignore this message, touch "$@",'
 	@echo 'but your build might not succeed.'
 	@exit 1
 
 config.status: $(configure_dir)/configure
-	@echo 'STOP!  configure has changed and needs to be run in this build directory.'
-	@echo 'Please rerun configure.'
-	@echo 'To ignore this message, touch "config.status" in the build directory,'
+js/src/config.status: $(topsrcdir)/js/src/configure
+config.status js/src/config.status:
+	@echo 'STOP!  $^ has changed and needs to be run again.'
+	@echo 'Please rerun it.'
+	@echo 'To ignore this message, touch "$(CURDIR)/$@",'
 	@echo 'but your build might not succeed.'
 	@exit 1
 
 # Regenerate the build backend if it is out of date. We only have this rule in
 # this main make file because having it in rules.mk and applied to partial tree
 # builds resulted in a world of hurt. Gory details are in bug 877308.
 #
 # The mach build driver will ensure the backend is up to date for partial tree
@@ -91,57 +87,51 @@ backend.RecursiveMakeBackend:
 
 Makefile: backend.RecursiveMakeBackend
 	@$(TOUCH) $@
 
 include backend.RecursiveMakeBackend.pp
 
 default:: backend.RecursiveMakeBackend
 
-ifdef BUILD_JS
-.PHONY: js-config-status
-js-config-status:
-	$(call SUBMAKE,backend.RecursiveMakeBackend,js/src,1)
-endif
-
 install_manifests := bin idl include public private sdk
 install_manifest_depends = \
   CLOBBER \
   $(configure_dir)/configure \
   config.status \
   backend.RecursiveMakeBackend \
   $(NULL)
 
-ifdef BUILD_JS
-install_manifest_depends += js-config-status
+ifndef JS_STANDALONE
+install_manifest_depends += \
+  $(topsrcdir)/js/src/configure \
+  js/src/config.status \
+  $(NULL)
 endif
 
 .PHONY: install-manifests
 install-manifests: $(addprefix install-dist-,$(install_manifests))
 
 # process_install_manifest needs to be invoked with --no-remove when building
 # js as standalone because automated builds are building nspr separately and
-# that would remove the resulting files. It is also necessary when building
-# js as part of gecko because that would remove the files exported from gecko.
+# that would remove the resulting files.
 # Eventually, a standalone js build would just be able to build nspr itself,
-# removing the need for the former. But that won't likely happen before
-# finishing to merge gecko and js build systems, removing the need for the
-# latter.
+# removing the need for the former.
 ifdef BUILDING_JS
 NO_REMOVE=1
 endif
 
 .PHONY: $(addprefix install-dist-,$(install_manifests))
 $(addprefix install-dist-,$(install_manifests)): install-dist-%: $(install_manifest_depends)
-	$(call py_action,process_install_manifest,$(if $(NO_REMOVE),--no-remove )$(DIST)/$* _build_manifests/install/dist_$* $(if $(BUILD_JS),js/src/_build_manifests/install/dist_$*))
+	$(call py_action,process_install_manifest,$(if $(NO_REMOVE),--no-remove )$(DIST)/$* _build_manifests/install/dist_$*)
 
 .PHONY: install-tests
 install-manifests: install-tests
 install-tests: $(install_manifest_depends)
-	$(call py_action,process_install_manifest,$(if $(NO_REMOVE),--no-remove )_tests _build_manifests/install/tests $(if $(BUILD_JS),js/src/_build_manifests/install/tests))
+	$(call py_action,process_install_manifest,$(if $(NO_REMOVE),--no-remove )_tests _build_manifests/install/tests)
 
 
 # _tests should be purged during cleaning. However, we don't want it purged
 # during PGO builds because it contains some auto-generated files.
 ifneq ($(filter-out maybe_clobber_profiledbuild,$(MAKECMDGOALS)),)
 GARBAGE_DIRS += _tests
 endif
 
@@ -289,24 +279,19 @@ check-%:
 source-package install:
 	$(MAKE) -C js/src $@
 
 # Every export rule depends on config/export, but the rule for config/export
 # doesn't exist when building js non-standalone.
 .PHONY: config/export
 config/export:
 
-else
-
-ifdef BUILD_JS
-js/src/Makefile: subsrcdir := js/src
+endif
 
 ifdef MOZ_PSEUDO_DERECURSE
 # Interdependencies for parallel export.
 js/xpconnect/src/export: dom/bindings/export xpcom/xpidl/export
 accessible/src/xpcom/export: xpcom/xpidl/export
 js/src/export: mfbt/export
 ifdef ENABLE_CLANG_PLUGIN
 js/src/export config/export: build/clang-plugin/export
 endif
 endif
-endif
-endif
--- a/build/autoconf/config.status.m4
+++ b/build/autoconf/config.status.m4
@@ -50,17 +50,17 @@ define([_MOZ_AC_DEFINE_UNQUOTED], defn([
 define([AC_DEFINE_UNQUOTED],
 [cat >> confdefs.pytmp <<EOF
     (''' $1 ''', ifelse($#, 2, [r''' $2 '''], $#, 3, [r''' $2 '''], ' 1 '))
 EOF
 ifelse($#, 2, _MOZ_AC_DEFINE_UNQUOTED($1, $2), $#, 3, _MOZ_AC_DEFINE_UNQUOTED($1, $2, $3),_MOZ_AC_DEFINE_UNQUOTED($1))dnl
 ])
 
 dnl Replace AC_OUTPUT to create and call a python config.status
-define([_MOZ_AC_OUTPUT],
+define([MOZ_CREATE_CONFIG_STATUS],
 [dnl Top source directory in Windows format (as opposed to msys format).
 WIN_TOP_SRC=
 encoding=utf-8
 case "$host_os" in
 mingw*)
     WIN_TOP_SRC=`cd $srcdir; pwd -W`
     encoding=mbcs
     ;;
@@ -94,17 +94,18 @@ cat > $CONFIG_STATUS <<EOF
 
 import os
 import types
 dnl topsrcdir is the top source directory in native form, as opposed to a
 dnl form suitable for make.
 topsrcdir = '''${WIN_TOP_SRC:-$srcdir}'''
 if not os.path.isabs(topsrcdir):
     rel = os.path.join(os.path.dirname(<<<__file__>>>), topsrcdir)
-    topsrcdir = os.path.normpath(os.path.abspath(rel))
+    topsrcdir = os.path.abspath(rel)
+topsrcdir = os.path.normpath(topsrcdir)
 
 topobjdir = os.path.abspath(os.path.dirname(<<<__file__>>>))
 
 dnl All defines and substs are stored with an additional space at the beginning
 dnl and at the end of the string, to avoid any problem with values starting or
 dnl ending with quotes.
 defines = [(name[1:-1], value[1:-1]) for name, value in [
 EOF
@@ -144,40 +145,53 @@ if test -n "$_NON_GLOBAL_ACDEFINES"; the
     echo "    '$var'," >> $CONFIG_STATUS
   done
 fi
 
 cat >> $CONFIG_STATUS <<EOF
 ]
 
 __all__ = ['topobjdir', 'topsrcdir', 'defines', 'non_global_defines', 'substs']
+EOF
 
+# We don't want js/src/config.status to do anything in gecko builds.
+if test -z "$BUILDING_JS" -o -n "$JS_STANDALONE"; then
+
+    cat >> $CONFIG_STATUS <<EOF
 dnl Do the actual work
 if __name__ == '__main__':
     args = dict([(name, globals()[name]) for name in __all__])
     from mozbuild.config_status import config_status
     config_status(**args)
 EOF
+
+fi
+
 changequote([, ])
+])
+
+define([MOZ_RUN_CONFIG_STATUS],
+[
 chmod +x $CONFIG_STATUS
 rm -fr confdefs* $ac_clean_files
 dnl Execute config.status, unless --no-create was passed to configure.
 if test "$no_create" != yes && ! ${PYTHON} $CONFIG_STATUS; then
     trap '' EXIT
     exit 1
 fi
 ])
 
 define([m4_fatal],[
 errprint([$1
 ])
 m4exit(1)
 ])
 
-define([AC_OUTPUT], [ifelse($#_$1, 1_, [_MOZ_AC_OUTPUT()],
+define([AC_OUTPUT], [ifelse($#_$1, 1_, [MOZ_CREATE_CONFIG_STATUS()
+MOZ_RUN_CONFIG_STATUS()],
 [m4_fatal([Use CONFIGURE_SUBST_FILES in moz.build files to create substituted files.])]
 )])
 
 define([AC_CONFIG_HEADER],
 [m4_fatal([Use CONFIGURE_DEFINE_FILES in moz.build files to produce header files.])
 ])
 
 AC_SUBST([MOZ_PSEUDO_DERECURSE])
--- a/build/autoconf/ffi.m4
+++ b/build/autoconf/ffi.m4
@@ -18,71 +18,75 @@ if test -n "$MOZ_NATIVE_FFI"; then
     fi
 fi
 
 AC_SUBST(MOZ_NATIVE_FFI)
 
 ])
 
 AC_DEFUN([MOZ_SUBCONFIGURE_FFI], [
-if test "$BUILD_CTYPES" -a -z "$MOZ_NATIVE_FFI"; then
-  # Run the libffi 'configure' script.
-  ac_configure_args="--disable-shared --enable-static --disable-raw-api"
-  if test "$MOZ_DEBUG"; then
-    ac_configure_args="$ac_configure_args --enable-debug"
-  fi
-  if test "$DSO_PIC_CFLAGS"; then
-    ac_configure_args="$ac_configure_args --with-pic"
-  fi
-  for var in AS CC CXX CPP LD AR RANLIB STRIP; do
-    ac_configure_args="$ac_configure_args $var='`eval echo \\${${var}}`'"
-  done
-  if test "$CROSS_COMPILE"; then
-    export CPPFLAGS CFLAGS LDFLAGS
-  fi
-  ac_configure_args="$ac_configure_args --build=$build --host=$target"
-  if test "$_MSC_VER"; then
-    # Use a wrapper script for cl and ml that looks more like gcc.
-    # autotools can't quite handle an MSVC build environment yet.
-    LDFLAGS=
-    CFLAGS=
-    ac_configure_args="$ac_configure_args LD=link CPP=\"cl -nologo -EP\" SHELL=sh.exe"
-    case "${target_cpu}" in
-    x86_64)
-      # Need target since MSYS tools into mozilla-build may be 32bit
-      ac_configure_args="$ac_configure_args CC=\"$_topsrcdir/js/src/ctypes/libffi/msvcc.sh -m64\""
-      ;;
-    *)
-      ac_configure_args="$ac_configure_args CC=$_topsrcdir/js/src/ctypes/libffi/msvcc.sh"
-      ;;
-    esac
-  fi
-  if test "$SOLARIS_SUNPRO_CC"; then
-    # Always use gcc for libffi on Solaris
-    if test ! "$HAVE_64BIT_OS"; then
-      ac_configure_args="$ac_configure_args CC=gcc CFLAGS=-m32 LD= LDFLAGS="
-    else
-      ac_configure_args="$ac_configure_args CC=gcc CFLAGS=-m64 LD= LDFLAGS="
+if test -z "$BUILDING_JS" -o -n "$JS_STANDALONE"; then
+
+  if test "$BUILD_CTYPES" -a -z "$MOZ_NATIVE_FFI"; then
+    # Run the libffi 'configure' script.
+    ac_configure_args="--disable-shared --enable-static --disable-raw-api"
+    if test "$MOZ_DEBUG"; then
+      ac_configure_args="$ac_configure_args --enable-debug"
+    fi
+    if test "$DSO_PIC_CFLAGS"; then
+      ac_configure_args="$ac_configure_args --with-pic"
+    fi
+    for var in AS CC CXX CPP LD AR RANLIB STRIP; do
+      ac_configure_args="$ac_configure_args $var='`eval echo \\${${var}}`'"
+    done
+    if test "$CROSS_COMPILE"; then
+      export CPPFLAGS CFLAGS LDFLAGS
     fi
-  fi
-  if test "$AIX_IBM_XLC"; then
-    # Always use gcc for libffi on IBM AIX5/AIX6
-    if test ! "$HAVE_64BIT_OS"; then
-      ac_configure_args="$ac_configure_args CC=gcc CFLAGS=-maix32"
-    else
-      ac_configure_args="$ac_configure_args CC=gcc CFLAGS=-maix64"
+    ac_configure_args="$ac_configure_args --build=$build --host=$target"
+    if test "$_MSC_VER"; then
+      # Use a wrapper script for cl and ml that looks more like gcc.
+      # autotools can't quite handle an MSVC build environment yet.
+      LDFLAGS=
+      CFLAGS=
+      ac_configure_args="$ac_configure_args LD=link CPP=\"cl -nologo -EP\" SHELL=sh.exe"
+      case "${target_cpu}" in
+      x86_64)
+        # Need target since MSYS tools into mozilla-build may be 32bit
+        ac_configure_args="$ac_configure_args CC=\"$_topsrcdir/js/src/ctypes/libffi/msvcc.sh -m64\""
+        ;;
+      *)
+        ac_configure_args="$ac_configure_args CC=$_topsrcdir/js/src/ctypes/libffi/msvcc.sh"
+        ;;
+      esac
     fi
+    if test "$SOLARIS_SUNPRO_CC"; then
+      # Always use gcc for libffi on Solaris
+      if test ! "$HAVE_64BIT_OS"; then
+        ac_configure_args="$ac_configure_args CC=gcc CFLAGS=-m32 LD= LDFLAGS="
+      else
+        ac_configure_args="$ac_configure_args CC=gcc CFLAGS=-m64 LD= LDFLAGS="
+      fi
+    fi
+    if test "$AIX_IBM_XLC"; then
+      # Always use gcc for libffi on IBM AIX5/AIX6
+      if test ! "$HAVE_64BIT_OS"; then
+        ac_configure_args="$ac_configure_args CC=gcc CFLAGS=-maix32"
+      else
+        ac_configure_args="$ac_configure_args CC=gcc CFLAGS=-maix64"
+      fi
+    fi
+
+    # Use a separate cache file for libffi, since it does things differently
+    # from our configure.
+    mkdir -p $_objdir/js/src/ctypes/libffi
+    old_cache_file=$cache_file
+    cache_file=$_objdir/js/src/ctypes/libffi/config.cache
+    old_config_files=$CONFIG_FILES
+    unset CONFIG_FILES
+    AC_OUTPUT_SUBDIRS(js/src/ctypes/libffi)
+    cache_file=$old_cache_file
+    ac_configure_args="$_SUBDIR_CONFIG_ARGS"
+    CONFIG_FILES=$old_config_files
   fi
 
-  # Use a separate cache file for libffi, since it does things differently
-  # from our configure.
-  mkdir -p $_objdir/js/src/ctypes/libffi
-  old_cache_file=$cache_file
-  cache_file=$_objdir/js/src/ctypes/libffi/config.cache
-  old_config_files=$CONFIG_FILES
-  unset CONFIG_FILES
-  AC_OUTPUT_SUBDIRS(js/src/ctypes/libffi)
-  cache_file=$old_cache_file
-  ac_configure_args="$_SUBDIR_CONFIG_ARGS"
-  CONFIG_FILES=$old_config_files
 fi
 ])
 
--- a/build/autoconf/icu.m4
+++ b/build/autoconf/icu.m4
@@ -84,36 +84,36 @@ if test -n "$ENABLE_INTL_API"; then
         case "$OS_TARGET" in
             WINNT)
                 ICU_LIB_NAMES="icuin icuuc icudt"
                 if test -n "$MOZ_SHARED_ICU"; then
                     DBG_SUFFIX=
                     if test -n "$MOZ_DEBUG"; then
                         DBG_SUFFIX=d
                     fi
-                    MOZ_ICU_LIBS='$(foreach lib,$(ICU_LIB_NAMES),$(DEPTH)$1/intl/icu/target/lib/$(LIB_PREFIX)$(lib)$(DBG_SUFFIX).$(LIB_SUFFIX))'
+                    MOZ_ICU_LIBS='$(foreach lib,$(ICU_LIB_NAMES),$(DEPTH)/intl/icu/target/lib/$(LIB_PREFIX)$(lib)$(DBG_SUFFIX).$(LIB_SUFFIX))'
                 fi
                 ;;
             Darwin)
                 ICU_LIB_NAMES="icui18n icuuc icudata"
                 if test -n "$MOZ_SHARED_ICU"; then
-                   MOZ_ICU_LIBS='$(foreach lib,$(ICU_LIB_NAMES),$(DEPTH)$1/intl/icu/target/lib/$(DLL_PREFIX)$(lib).$(MOZ_ICU_VERSION)$(DLL_SUFFIX))'
+                   MOZ_ICU_LIBS='$(foreach lib,$(ICU_LIB_NAMES),$(DEPTH)/intl/icu/target/lib/$(DLL_PREFIX)$(lib).$(MOZ_ICU_VERSION)$(DLL_SUFFIX))'
                 fi
                 ;;
             Linux|DragonFly|FreeBSD|NetBSD|OpenBSD)
                 ICU_LIB_NAMES="icui18n icuuc icudata"
                 if test -n "$MOZ_SHARED_ICU"; then
-                   MOZ_ICU_LIBS='$(foreach lib,$(ICU_LIB_NAMES),$(DEPTH)$1/intl/icu/target/lib/$(DLL_PREFIX)$(lib)$(DLL_SUFFIX).$(MOZ_ICU_VERSION))'
+                   MOZ_ICU_LIBS='$(foreach lib,$(ICU_LIB_NAMES),$(DEPTH)/intl/icu/target/lib/$(DLL_PREFIX)$(lib)$(DLL_SUFFIX).$(MOZ_ICU_VERSION))'
                 fi
                 ;;
             *)
                 AC_MSG_ERROR([ECMAScript Internationalization API is not yet supported on this platform])
         esac
         if test -z "$MOZ_SHARED_ICU"; then
-            MOZ_ICU_LIBS='$(call EXPAND_LIBNAME_PATH,$(ICU_LIB_NAMES),$(DEPTH)$1/intl/icu/target/lib)'
+            MOZ_ICU_LIBS='$(call EXPAND_LIBNAME_PATH,$(ICU_LIB_NAMES),$(DEPTH)/intl/icu/target/lib)'
         fi
     fi
 fi
 
 AC_SUBST(DBG_SUFFIX)
 AC_SUBST(ENABLE_INTL_API)
 AC_SUBST(ICU_LIB_NAMES)
 AC_SUBST(MOZ_ICU_LIBS)
@@ -129,194 +129,199 @@ if test -n "$ENABLE_INTL_API" -a -z "$MO
     dnl namespace they want to use.
     AC_DEFINE(U_USING_ICU_NAMESPACE,0)
 fi
 
 
 ])
 
 AC_DEFUN([MOZ_SUBCONFIGURE_ICU], [
-if test -n "$ENABLE_INTL_API" -a -z "$MOZ_NATIVE_ICU"; then
-    # Set ICU compile options
-    ICU_CPPFLAGS=""
-    # don't use icu namespace automatically in client code
-    ICU_CPPFLAGS="$ICU_CPPFLAGS -DU_USING_ICU_NAMESPACE=0"
-    # don't include obsolete header files
-    ICU_CPPFLAGS="$ICU_CPPFLAGS -DU_NO_DEFAULT_INCLUDE_UTF_HEADERS=1"
-    # remove chunks of the library that we don't need (yet)
-    ICU_CPPFLAGS="$ICU_CPPFLAGS -DUCONFIG_NO_LEGACY_CONVERSION"
-    ICU_CPPFLAGS="$ICU_CPPFLAGS -DUCONFIG_NO_TRANSLITERATION"
-    ICU_CPPFLAGS="$ICU_CPPFLAGS -DUCONFIG_NO_REGULAR_EXPRESSIONS"
-    ICU_CPPFLAGS="$ICU_CPPFLAGS -DUCONFIG_NO_BREAK_ITERATION"
+
+if test -z "$BUILDING_JS" -o -n "$JS_STANDALONE"; then
+
+    if test -n "$ENABLE_INTL_API" -a -z "$MOZ_NATIVE_ICU"; then
+        # Set ICU compile options
+        ICU_CPPFLAGS=""
+        # don't use icu namespace automatically in client code
+        ICU_CPPFLAGS="$ICU_CPPFLAGS -DU_USING_ICU_NAMESPACE=0"
+        # don't include obsolete header files
+        ICU_CPPFLAGS="$ICU_CPPFLAGS -DU_NO_DEFAULT_INCLUDE_UTF_HEADERS=1"
+        # remove chunks of the library that we don't need (yet)
+        ICU_CPPFLAGS="$ICU_CPPFLAGS -DUCONFIG_NO_LEGACY_CONVERSION"
+        ICU_CPPFLAGS="$ICU_CPPFLAGS -DUCONFIG_NO_TRANSLITERATION"
+        ICU_CPPFLAGS="$ICU_CPPFLAGS -DUCONFIG_NO_REGULAR_EXPRESSIONS"
+        ICU_CPPFLAGS="$ICU_CPPFLAGS -DUCONFIG_NO_BREAK_ITERATION"
+
+        ICU_CROSS_BUILD_OPT=""
+        ICU_SRCDIR=""
+        if test "$HOST_OS_ARCH" = "WINNT"; then
+    	ICU_SRCDIR="--srcdir=$(cd $srcdir/intl/icu/source; pwd -W)"
+        fi
 
-    ICU_CROSS_BUILD_OPT=""
-    ICU_SRCDIR=""
-    if test "$HOST_OS_ARCH" = "WINNT"; then
-        ICU_SRCDIR="--srcdir=$(cd $srcdir/intl/icu/source; pwd -W)"
-    fi
+        if test "$CROSS_COMPILE"; then
+    	# Building host tools.  It is necessary to build target binary.
+    	case "$HOST_OS_ARCH" in
+    	    Darwin)
+    		ICU_TARGET=MacOSX
+    		;;
+    	    Linux)
+    		ICU_TARGET=Linux
+    		;;
+    	    WINNT)
+    		ICU_TARGET=MSYS/MSVC
+    		;;
+    	    *bsd*|dragonfly*)
+    		ICU_TARGET=BSD
+    		;;
+    	esac
+    	# Remove _DEPEND_CFLAGS from HOST_FLAGS to avoid configure error
+    	HOST_ICU_CFLAGS="$HOST_CFLAGS"
+    	HOST_ICU_CXXFLAGS="$HOST_CXXFLAGS"
+
+    	HOST_ICU_CFLAGS=`echo $HOST_ICU_CFLAGS | sed "s|$_DEPEND_CFLAGS||g"`
+    	HOST_ICU_CXXFLAGS=`echo $HOST_ICU_CFXXLAGS | sed "s|$_DEPEND_CFLAGS||g"`
+
+    	# ICU requires RTTI
+    	if test "$GNU_CC"; then
+    	    HOST_ICU_CXXFLAGS=`echo $HOST_ICU_CXXFLAGS | sed 's|-fno-rtti|-frtti|g'`
+    	elif test "$_MSC_VER"; then
+    	    HOST_ICU_CXXFLAGS=`echo $HOST_ICU_CXXFLAGS | sed 's|-GR-|-GR|g'`
+    	fi
+
+    	HOST_ICU_BUILD_OPTS=""
+    	if test -n "$MOZ_DEBUG"; then
+    	    HOST_ICU_BUILD_OPTS="$HOST_ICU_BUILD_OPTS --enable-debug"
+    	fi
 
-    if test "$CROSS_COMPILE"; then
-        # Building host tools.  It is necessary to build target binary.
-        case "$HOST_OS_ARCH" in
-            Darwin)
-                ICU_TARGET=MacOSX
-                ;;
-            Linux)
-                ICU_TARGET=Linux
-                ;;
-            WINNT)
-                ICU_TARGET=MSYS/MSVC
-                ;;
-            *bsd*|dragonfly*)
-                ICU_TARGET=BSD
-                ;;
-        esac
-        # Remove _DEPEND_CFLAGS from HOST_FLAGS to avoid configure error
-        HOST_ICU_CFLAGS="$HOST_CFLAGS"
-        HOST_ICU_CXXFLAGS="$HOST_CXXFLAGS"
+    	abs_srcdir=`(cd $srcdir; pwd)`
+    	mkdir -p $_objdir/intl/icu/host
+    	(cd $_objdir/intl/icu/host
+    	 MOZ_SUBCONFIGURE_WRAP([.],[
+    	 AR="$HOST_AR" RANLIB="$HOST_RANLIB" \
+    	 CC="$HOST_CC" CXX="$HOST_CXX" LD="$HOST_LD" \
+    	 CFLAGS="$HOST_ICU_CFLAGS $HOST_OPTIMIZE_FLAGS" \
+    	 CPPFLAGS="$ICU_CPPFLAGS" \
+    	 CXXFLAGS="$HOST_ICU_CXXFLAGS $HOST_OPTIMIZE_FLAGS" \
+    	 LDFLAGS="$HOST_LDFLAGS" \
+    		$SHELL $abs_srcdir/intl/icu/source/runConfigureICU \
+    		$HOST_ICU_BUILD_OPTS \
+    		$ICU_TARGET \
+    	dnl Shell quoting is fun.
+    		${ICU_SRCDIR+"$ICU_SRCDIR"} \
+    		--enable-static --disable-shared \
+    		--enable-extras=no --enable-icuio=no --enable-layout=no \
+    		--enable-tests=no --enable-samples=no || exit 1
+    	 ])
+    	) || exit 1
+    	# generate config/icucross.mk
+    	$GMAKE -C $_objdir/intl/icu/host/ config/icucross.mk
+
+    	# --with-cross-build requires absolute path
+    	ICU_HOST_PATH=`cd $_objdir/intl/icu/host && pwd`
+    	ICU_CROSS_BUILD_OPT="--with-cross-build=$ICU_HOST_PATH"
+    	ICU_TARGET_OPT="--build=$build --host=$target"
+        else
+    	# CROSS_COMPILE isn't set build and target are i386 and x86-64.
+    	# So we must set target for --build and --host.
+    	ICU_TARGET_OPT="--build=$target --host=$target"
+        fi
 
-        HOST_ICU_CFLAGS=`echo $HOST_ICU_CFLAGS | sed "s|$_DEPEND_CFLAGS||g"`
-        HOST_ICU_CXXFLAGS=`echo $HOST_ICU_CFXXLAGS | sed "s|$_DEPEND_CFLAGS||g"`
+        if test -z "$MOZ_SHARED_ICU"; then
+    	# To reduce library size, use static linking
+    	ICU_LINK_OPTS="--enable-static --disable-shared"
+        else
+    	ICU_LINK_OPTS="--disable-static --enable-shared"
+        fi
+        # Force the ICU static libraries to be position independent code
+        ICU_CFLAGS="$DSO_PIC_CFLAGS $CFLAGS"
+        ICU_CXXFLAGS="$DSO_PIC_CFLAGS $CXXFLAGS"
+
+        ICU_BUILD_OPTS=""
+        if test -n "$MOZ_DEBUG" -o "MOZ_DEBUG_SYMBOLS"; then
+    	ICU_CFLAGS="$ICU_CFLAGS $MOZ_DEBUG_FLAGS"
+    	ICU_CXXFLAGS="$ICU_CXXFLAGS $MOZ_DEBUG_FLAGS"
+    	if test -n "$CROSS_COMPILE" -a "$OS_TARGET" = "Darwin" \
+    		-a "$HOST_OS_ARCH" != "Darwin"
+    	then
+    	    # Bug 951758: Cross-OSX builds with non-Darwin hosts have issues
+    	    # with -g and friends (like -gdwarf and -gfull) because they try
+    	    # to run dsymutil
+    	    changequote(,)
+    	    ICU_CFLAGS=`echo $ICU_CFLAGS | sed 's|-g[^ \t]*||g'`
+    	    ICU_CXXFLAGS=`echo $ICU_CXXFLAGS | sed 's|-g[^ \t]*||g'`
+    	    changequote([,])
+    	fi
+
+    	ICU_LDFLAGS="$MOZ_DEBUG_LDFLAGS"
+    	if test -z "$MOZ_DEBUG"; then
+    	    # To generate debug symbols, it requires MOZ_DEBUG_FLAGS.
+    	    # But, not debug build.
+    	    ICU_CFLAGS="$ICU_CFLAGS -UDEBUG -DNDEBUG"
+    	    ICU_CXXFLAGS="$ICU_CXXFLAGS -UDEBUG -DNDEBUG"
+    	else
+    	    ICU_BUILD_OPTS="$ICU_BUILD_OPTS --enable-debug"
+    	fi
+        fi
+        if test -z "$MOZ_OPTIMIZE"; then
+    	ICU_BUILD_OPTS="$ICU_BUILD_OPTS --disable-release"
+        else
+    	ICU_CFLAGS="$ICU_CFLAGS $MOZ_OPTIMIZE_FLAGS"
+    	ICU_CXXFLAGS="$ICU_CXXFLAGS $MOZ_OPTIMIZE_FLAGS"
+        fi
+
+        if test "$am_cv_langinfo_codeset" = "no"; then
+    	# ex. Android
+    	ICU_CPPFLAGS="$ICU_CPPFLAGS -DU_HAVE_NL_LANGINFO_CODESET=0"
+        fi
 
         # ICU requires RTTI
         if test "$GNU_CC"; then
-            HOST_ICU_CXXFLAGS=`echo $HOST_ICU_CXXFLAGS | sed 's|-fno-rtti|-frtti|g'`
-        elif test "$_MSC_VER"; then
-            HOST_ICU_CXXFLAGS=`echo $HOST_ICU_CXXFLAGS | sed 's|-GR-|-GR|g'`
-        fi
-
-        HOST_ICU_BUILD_OPTS=""
-        if test -n "$MOZ_DEBUG"; then
-            HOST_ICU_BUILD_OPTS="$HOST_ICU_BUILD_OPTS --enable-debug"
-        fi
-
-        abs_srcdir=`(cd $srcdir; pwd)`
-        mkdir -p $_objdir/intl/icu/host
-        (cd $_objdir/intl/icu/host
-         MOZ_SUBCONFIGURE_WRAP([.],[
-         AR="$HOST_AR" RANLIB="$HOST_RANLIB" \
-         CC="$HOST_CC" CXX="$HOST_CXX" LD="$HOST_LD" \
-         CFLAGS="$HOST_ICU_CFLAGS $HOST_OPTIMIZE_FLAGS" \
-         CPPFLAGS="$ICU_CPPFLAGS" \
-         CXXFLAGS="$HOST_ICU_CXXFLAGS $HOST_OPTIMIZE_FLAGS" \
-         LDFLAGS="$HOST_LDFLAGS" \
-                $SHELL $abs_srcdir/intl/icu/source/runConfigureICU \
-                $HOST_ICU_BUILD_OPTS \
-                $ICU_TARGET \
-        dnl Shell quoting is fun.
-                ${ICU_SRCDIR+"$ICU_SRCDIR"} \
-                --enable-static --disable-shared \
-                --enable-extras=no --enable-icuio=no --enable-layout=no \
-                --enable-tests=no --enable-samples=no || exit 1
-         ])
-        ) || exit 1
-        # generate config/icucross.mk
-        $GMAKE -C $_objdir/intl/icu/host/ config/icucross.mk
+    	ICU_CXXFLAGS=`echo $ICU_CXXFLAGS | sed 's|-fno-rtti|-frtti|g'`
+        else
+    	if test "$_MSC_VER"; then
+    	    ICU_CXXFLAGS=`echo $ICU_CXXFLAGS | sed 's|-GR-|-GR|g'`
+    	fi
 
-        # --with-cross-build requires absolute path
-        ICU_HOST_PATH=`cd $_objdir/intl/icu/host && pwd`
-        ICU_CROSS_BUILD_OPT="--with-cross-build=$ICU_HOST_PATH"
-        ICU_TARGET_OPT="--build=$build --host=$target"
-    else
-        # CROSS_COMPILE isn't set build and target are i386 and x86-64.
-        # So we must set target for --build and --host.
-        ICU_TARGET_OPT="--build=$target --host=$target"
-    fi
+    	# Add RTL flags for MSVCRT.DLL
+    	if test -n "$MOZ_DEBUG"; then
+    	    ICU_CFLAGS="$ICU_CFLAGS -MDd"
+    	    ICU_CXXFLAGS="$ICU_CXXFLAGS -MDd"
+    	else
+    	    ICU_CFLAGS="$ICU_CFLAGS -MD"
+    	    ICU_CXXFLAGS="$ICU_CXXFLAGS -MD"
+    	fi
 
-    if test -z "$MOZ_SHARED_ICU"; then
-        # To reduce library size, use static linking
-        ICU_LINK_OPTS="--enable-static --disable-shared"
-    else
-        ICU_LINK_OPTS="--disable-static --enable-shared"
-    fi
-    # Force the ICU static libraries to be position independent code
-    ICU_CFLAGS="$DSO_PIC_CFLAGS $CFLAGS"
-    ICU_CXXFLAGS="$DSO_PIC_CFLAGS $CXXFLAGS"
-
-    ICU_BUILD_OPTS=""
-    if test -n "$MOZ_DEBUG" -o "MOZ_DEBUG_SYMBOLS"; then
-        ICU_CFLAGS="$ICU_CFLAGS $MOZ_DEBUG_FLAGS"
-        ICU_CXXFLAGS="$ICU_CXXFLAGS $MOZ_DEBUG_FLAGS"
-        if test -n "$CROSS_COMPILE" -a "$OS_TARGET" = "Darwin" \
-                -a "$HOST_OS_ARCH" != "Darwin"
-        then
-            # Bug 951758: Cross-OSX builds with non-Darwin hosts have issues
-            # with -g and friends (like -gdwarf and -gfull) because they try
-            # to run dsymutil
-            changequote(,)
-            ICU_CFLAGS=`echo $ICU_CFLAGS | sed 's|-g[^ \t]*||g'`
-            ICU_CXXFLAGS=`echo $ICU_CXXFLAGS | sed 's|-g[^ \t]*||g'`
-            changequote([,])
+    	# add disable optimize flag for workaround for bug 899948
+    	if test -z "$MOZ_OPTIMIZE"; then
+    	    ICU_CFLAGS="$ICU_CFLAGS -Od"
+    	    ICU_CXXFLAGS="$ICU_CXXFLAGS -Od"
+    	fi
         fi
 
-        ICU_LDFLAGS="$MOZ_DEBUG_LDFLAGS"
-        if test -z "$MOZ_DEBUG"; then
-            # To generate debug symbols, it requires MOZ_DEBUG_FLAGS.
-            # But, not debug build.
-            ICU_CFLAGS="$ICU_CFLAGS -UDEBUG -DNDEBUG"
-            ICU_CXXFLAGS="$ICU_CXXFLAGS -UDEBUG -DNDEBUG"
-        else
-            ICU_BUILD_OPTS="$ICU_BUILD_OPTS --enable-debug"
-        fi
-    fi
-    if test -z "$MOZ_OPTIMIZE"; then
-        ICU_BUILD_OPTS="$ICU_BUILD_OPTS --disable-release"
-    else
-        ICU_CFLAGS="$ICU_CFLAGS $MOZ_OPTIMIZE_FLAGS"
-        ICU_CXXFLAGS="$ICU_CXXFLAGS $MOZ_OPTIMIZE_FLAGS"
-    fi
-
-    if test "$am_cv_langinfo_codeset" = "no"; then
-        # ex. Android
-        ICU_CPPFLAGS="$ICU_CPPFLAGS -DU_HAVE_NL_LANGINFO_CODESET=0"
+        # We cannot use AC_OUTPUT_SUBDIRS since ICU tree is out of spidermonkey.
+        # When using AC_OUTPUT_SUBDIRS, objdir of ICU is out of objdir
+        # due to relative path.
+        # If building ICU moves into root of mozilla tree, we can use
+        # AC_OUTPUT_SUBDIR instead.
+        mkdir -p $_objdir/intl/icu/target
+        (cd $_objdir/intl/icu/target
+         MOZ_SUBCONFIGURE_WRAP([.],[
+           AR="$AR" CC="$CC" CXX="$CXX" LD="$LD" \
+           ARFLAGS="$ARFLAGS" \
+           CPPFLAGS="$ICU_CPPFLAGS $CPPFLAGS" \
+           CFLAGS="$ICU_CFLAGS" \
+           CXXFLAGS="$ICU_CXXFLAGS" \
+           LDFLAGS="$ICU_LDFLAGS $LDFLAGS" \
+           $SHELL $_topsrcdir/intl/icu/source/configure \
+    		$ICU_BUILD_OPTS \
+    		$ICU_CROSS_BUILD_OPT \
+    		$ICU_LINK_OPTS \
+    		${ICU_SRCDIR+"$ICU_SRCDIR"} \
+    		$ICU_TARGET_OPT \
+    		--disable-extras --disable-icuio --disable-layout \
+    		--disable-tests --disable-samples || exit 1
+           ])
+        ) || exit 1
     fi
 
-    # ICU requires RTTI
-    if test "$GNU_CC"; then
-        ICU_CXXFLAGS=`echo $ICU_CXXFLAGS | sed 's|-fno-rtti|-frtti|g'`
-    else
-        if test "$_MSC_VER"; then
-            ICU_CXXFLAGS=`echo $ICU_CXXFLAGS | sed 's|-GR-|-GR|g'`
-        fi
-
-        # Add RTL flags for MSVCRT.DLL
-        if test -n "$MOZ_DEBUG"; then
-            ICU_CFLAGS="$ICU_CFLAGS -MDd"
-            ICU_CXXFLAGS="$ICU_CXXFLAGS -MDd"
-        else
-            ICU_CFLAGS="$ICU_CFLAGS -MD"
-            ICU_CXXFLAGS="$ICU_CXXFLAGS -MD"
-        fi
-
-        # add disable optimize flag for workaround for bug 899948
-        if test -z "$MOZ_OPTIMIZE"; then
-            ICU_CFLAGS="$ICU_CFLAGS -Od"
-            ICU_CXXFLAGS="$ICU_CXXFLAGS -Od"
-        fi
-    fi
-
-    # We cannot use AC_OUTPUT_SUBDIRS since ICU tree is out of spidermonkey.
-    # When using AC_OUTPUT_SUBDIRS, objdir of ICU is out of objdir
-    # due to relative path.
-    # If building ICU moves into root of mozilla tree, we can use
-    # AC_OUTPUT_SUBDIR instead.
-    mkdir -p $_objdir/intl/icu/target
-    (cd $_objdir/intl/icu/target
-     MOZ_SUBCONFIGURE_WRAP([.],[
-       AR="$AR" CC="$CC" CXX="$CXX" LD="$LD" \
-       ARFLAGS="$ARFLAGS" \
-       CPPFLAGS="$ICU_CPPFLAGS $CPPFLAGS" \
-       CFLAGS="$ICU_CFLAGS" \
-       CXXFLAGS="$ICU_CXXFLAGS" \
-       LDFLAGS="$ICU_LDFLAGS $LDFLAGS" \
-       $SHELL $_topsrcdir/intl/icu/source/configure \
-                $ICU_BUILD_OPTS \
-                $ICU_CROSS_BUILD_OPT \
-                $ICU_LINK_OPTS \
-                ${ICU_SRCDIR+"$ICU_SRCDIR"} \
-                $ICU_TARGET_OPT \
-                --disable-extras --disable-icuio --disable-layout \
-                --disable-tests --disable-samples || exit 1
-       ])
-    ) || exit 1
 fi
 
 ])
copy from config/autoconf.mk.in
copy to config/autoconf-js.mk.in
--- a/config/autoconf.mk.in
+++ b/config/autoconf-js.mk.in
@@ -1,6 +1,6 @@
 ifndef INCLUDED_AUTOCONF_MK
 INCLUDED_AUTOCONF_MK = 1
-include $(DEPTH)/config/emptyvars.mk
+include $(DEPTH)/config/emptyvars-js.mk
 @ALLSUBSTS@
 include $(topsrcdir)/config/baseconfig.mk
 endif
copy from config/emptyvars.mk.in
copy to config/emptyvars-js.mk.in
deleted file mode 100644
--- a/config/js/js.mozbuild
+++ /dev/null
@@ -1,7 +0,0 @@
-# vim: set filetype=python:
-# 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/.
-
-add_tier_dir('js', 'js/src', external=True)
-
--- a/config/static-checking-config.mk
+++ b/config/static-checking-config.mk
@@ -38,16 +38,12 @@ DEHYDRA_ARGS = \
 
 DEHYDRA_FLAGS = -fplugin=$(DEHYDRA_PATH) $(DEHYDRA_ARGS)
 
 ifdef DEHYDRA_PATH
 OS_CXXFLAGS += $(DEHYDRA_FLAGS)
 endif
 
 ifdef ENABLE_CLANG_PLUGIN
-ifndef BUILDING_JS
 CLANG_PLUGIN := $(DEPTH)/build/clang-plugin/$(DLL_PREFIX)clang-plugin$(DLL_SUFFIX)
-else
-CLANG_PLUGIN := $(DEPTH)/../../build/clang-plugin/$(DLL_PREFIX)clang-plugin$(DLL_SUFFIX)
-endif
 OS_CXXFLAGS += -Xclang -load -Xclang $(CLANG_PLUGIN) -Xclang -add-plugin -Xclang moz-check
 OS_CFLAGS += -Xclang -load -Xclang $(CLANG_PLUGIN) -Xclang -add-plugin -Xclang moz-check
 endif
--- a/configure.in
+++ b/configure.in
@@ -87,17 +87,16 @@ MOZ_USE_PTHREADS=
 _PTHREAD_LDFLAGS=""
 
 dnl Do not allow objdir == srcdir builds.
 dnl ==============================================================
 _topsrcdir=`cd \`dirname $0\`; pwd`
 _objdir=`pwd`
 
 
-
 dnl TODO Don't exempt L10N builds once bug 842760 is resolved.
 if test "$_topsrcdir" = "$_objdir" -a "${with_l10n_base+set}" != set; then
   echo "  ***"
   echo "  * Building directly in the main source directory is not allowed."
   echo "  *"
   echo "  * To build, you must run configure from a separate directory"
   echo "  * (referred to as an object directory)."
   echo "  *"
@@ -8702,25 +8701,29 @@ else
     # Internationalization isn't built or exposed by default in non-desktop
     # builds.  Bugs to enable:
     #
     #   Android:  bug 864843
     #   B2G:      bug 866301
     _INTL_API=no
 fi
 
-MOZ_CONFIG_ICU(/js/src)
+MOZ_CONFIG_ICU()
 
 if test -n "$MOZ_NATIVE_ICU"; then
     MOZ_JS_STATIC_LIBS="$MOZ_JS_STATIC_LIBS $MOZ_ICU_LIBS"
 fi
 
-export WRITE_MOZINFO=1
-AC_OUTPUT()
-unset WRITE_MOZINFO
+MOZ_CREATE_CONFIG_STATUS()
+
+# No need to run subconfigures when building with LIBXUL_SDK_DIR
+if test "$COMPILE_ENVIRONMENT" -a -z "$LIBXUL_SDK_DIR"; then
+  MOZ_SUBCONFIGURE_ICU()
+  MOZ_SUBCONFIGURE_FFI()
+fi
 
 # Hack around an Apple bug that affects the egrep that comes with OS X 10.7.
 # "env ARCHPREFERENCE=i386,x86_64 arch egrep" first tries to use the 32-bit
 # Intel part of the egrep fat binary, even on 64-bit systems, and falls back on
 # the 64-bit part if it's not a fat binary, as can happen with MacPorts. We
 # (apparently) only need this hack when egrep's "pattern" is particularly long
 # (as in the following code) and the first egrep on our $PATH is Apple's.  See
 # bug 655339.
@@ -8944,17 +8947,16 @@ if test -z "$JS_SHARED_LIBRARY" ; then
 fi
 if test -z "$JSGC_USE_EXACT_ROOTING" ; then
     ac_configure_args="$ac_configure_args --disable-exact-rooting"
 fi
 if test -z "$MOZ_NATIVE_NSPR"; then
     ac_configure_args="$ac_configure_args --with-nspr-cflags='$NSPR_CFLAGS'"
     ac_configure_args="$ac_configure_args --with-nspr-libs='$NSPR_LIBS'"
 fi
-ac_configure_args="$ac_configure_args --with-dist-dir=../../dist"
 ac_configure_args="$ac_configure_args --prefix=$dist"
 if test "$MOZ_MEMORY"; then
    ac_configure_args="$ac_configure_args --enable-jemalloc"
 fi
 if test -n "$MOZ_GLUE_LDFLAGS"; then
    export MOZ_GLUE_LDFLAGS
 fi
 if test -n "$MOZ_GLUE_PROGRAM_LDFLAGS"; then
@@ -8980,8 +8982,17 @@ export ZLIB_IN_MOZGLUE
 if ! test -e js; then
     mkdir js
 fi
 
 AC_OUTPUT_SUBDIRS(js/src)
 ac_configure_args="$_SUBDIR_CONFIG_ARGS"
 
 fi # COMPILE_ENVIRONMENT && !LIBXUL_SDK_DIR
+
+export WRITE_MOZINFO=1
+dnl we need to run config.status after js/src subconfigure because we're
+dnl traversing its moz.build and we need its config.status for that.
+dnl However, writing our own config.status needs to happen before
+dnl subconfigures because the setup surrounding subconfigures alters
+dnl many AC_SUBSTed variables.
+MOZ_RUN_CONFIG_STATUS()
+unset WRITE_MOZINFO
--- a/js/src/configure.in
+++ b/js/src/configure.in
@@ -154,24 +154,26 @@ else
   if test "$DISABLE_EXPORT_JS" = "1"; then
     AC_MSG_ERROR([Must export JS symbols when building a shared library.])
   fi
   JS_SHARED_LIBRARY=1
 fi
 AC_SUBST(JS_SHARED_LIBRARY)
 
 if test "$JS_STANDALONE" = no; then
+  autoconfmk=autoconf-js.mk
   JS_STANDALONE=
 else
   JS_STANDALONE=1
   AC_DEFINE(JS_STANDALONE)
 fi
 AC_SUBST(JS_STANDALONE)
 BUILDING_JS=1
 AC_SUBST(BUILDING_JS)
+AC_SUBST(autoconfmk)
 
 MOZ_ARG_WITH_STRING(gonk,
 [  --with-gonk=DIR
                location of gonk dir],
     gonkdir=$withval)
 
 MOZ_ARG_WITH_STRING(gonk-toolchain-prefix,
 [  --with-gonk-toolchain-prefix=DIR
@@ -3805,16 +3807,17 @@ dnl ====================================
 dnl = Build jsctypes if it's enabled
 dnl ========================================================
 MOZ_ARG_ENABLE_BOOL(ctypes,
 [  --enable-ctypes         Enable js-ctypes (default=no)],
     BUILD_CTYPES=1,
     BUILD_CTYPES= )
 JS_HAS_CTYPES=$BUILD_CTYPES
 AC_SUBST(JS_HAS_CTYPES)
+AC_SUBST(BUILD_CTYPES)
 if test "$JS_HAS_CTYPES"; then
   dnl Error out if we're on MSVC and MASM is unavailable.
   if test -n "$_MSC_VER" -a \( "$AS" != "ml.exe" -a "$AS" != "ml64.exe" \); then
     AC_MSG_ERROR([\"$AS\" is not a suitable assembler to build js-ctypes. If you are building with MS Visual Studio 8 Express, you may download the MASM 8.0 package, upgrade to Visual Studio 9 Express, or install the Vista SDK. Or do not use --enable-ctypes.])
   fi
   AC_DEFINE(JS_HAS_CTYPES)
 fi
 
@@ -4112,13 +4115,17 @@ if test -n "$GNU_CC"; then
 JS_CONFIG_MOZ_JS_LIBS='-L${libdir} -l${JS_LIBRARY_NAME}'
 else
 JS_CONFIG_MOZ_JS_LIBS='${libdir}/${JS_LIBRARY_NAME}.lib'
 fi
 AC_SUBST(JS_LIBRARY_NAME)
 AC_SUBST(JS_CONFIG_MOZ_JS_LIBS)
 AC_SUBST(JS_CONFIG_LIBS)
 
+MOZ_SUBCONFIGURE_FFI()
+
 dnl Spit out some output
 dnl ========================================================
-AC_OUTPUT()
-
-MOZ_SUBCONFIGURE_FFI()
+MOZ_CREATE_CONFIG_STATUS()
+
+if test "$JS_STANDALONE"; then
+  MOZ_RUN_CONFIG_STATUS()
+fi
--- a/js/src/moz.build
+++ b/js/src/moz.build
@@ -22,16 +22,22 @@ LIBRARY_NAME = CONFIG['JS_LIBRARY_NAME']
 
 CONFIGURE_SUBST_FILES += [
     'devtools/rootAnalysis/Makefile',
     'js-confdefs.h',
     'js-config',
     'js.pc',
 ]
 
+if not CONFIG['JS_STANDALONE']:
+    CONFIGURE_SUBST_FILES += [
+        '../../config/autoconf-js.mk',
+        '../../config/emptyvars-js.mk',
+    ]
+
 CONFIGURE_DEFINE_FILES += [
     'js-config.h',
 ]
 
 # Changes to internal header files, used externally, massively slow down
 # browser builds.  Don't add new files here unless you know what you're
 # doing!
 EXPORTS += [
--- a/moz.build
+++ b/moz.build
@@ -4,46 +4,58 @@
 # 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/.
 
 CONFIGURE_SUBST_FILES += [
     'config/autoconf.mk',
     'config/emptyvars.mk',
 ]
 
-if CONFIG['BUILDING_JS']:
-    if CONFIG['JS_STANDALONE']:
-        add_tier_dir('base', ['config', 'mfbt'])
-    if CONFIG['JS_HAS_CTYPES'] and not CONFIG['MOZ_NATIVE_FFI']:
-        add_tier_dir('js', ['js/src/ctypes/libffi'], static=True)
-    add_tier_dir('js', ['intl/icu'], static=True)
-    CONFIGURE_SUBST_FILES += ['intl/icu/Makefile']
-    add_tier_dir('js', ['js/src'])
-else:
+if CONFIG['ENABLE_CLANG_PLUGIN']:
+    add_tier_dir('base', 'build/clang-plugin', external=True)
+
+add_tier_dir('base', ['config', 'python'])
+if not CONFIG['JS_STANDALONE']:
     CONFIGURE_SUBST_FILES += [
         'mozilla-config.h',
         'tools/update-packaging/Makefile',
     ]
 
-    if CONFIG['ENABLE_CLANG_PLUGIN']:
-        add_tier_dir('base', 'build/clang-plugin', external=True)
+    add_tier_dir('base', ['build', 'probes'])
 
-    add_tier_dir('base', ['config', 'build', 'probes', 'python'])
+if not CONFIG['LIBXUL_SDK']:
+    add_tier_dir('base', ['mfbt'])
 
-    if not CONFIG['LIBXUL_SDK']:
-        add_tier_dir('base', ['mfbt'])
-
+    if not CONFIG['JS_STANDALONE']:
         if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('android', 'gonk'):
             if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk' and CONFIG['ANDROID_VERSION'] <= '18':
                 add_tier_dir('base', ['other-licenses/android'])
 
         if CONFIG['MOZ_MEMORY']:
             add_tier_dir('base', ['memory'])
 
         if not CONFIG['MOZ_NATIVE_ZLIB']:
             add_tier_dir('base', ['modules/zlib'])
 
         add_tier_dir('base', ['mozglue', 'memory/mozalloc'])
 
+if not CONFIG['JS_STANDALONE']:
     add_tier_dir('precompile', 'xpcom/xpidl')
 
+    if CONFIG['COMPILE_ENVIRONMENT'] and not CONFIG['LIBXUL_SDK']:
+        if not CONFIG['MOZ_NATIVE_NSPR']:
+            add_tier_dir('nspr', 'config/nspr')
+
+        add_tier_dir('external', 'config/external')
+
+        if not CONFIG['MOZ_NATIVE_NSS']:
+             add_tier_dir('nss', 'security/build')
+
+if CONFIG['COMPILE_ENVIRONMENT'] and not CONFIG['LIBXUL_SDK']:
+    if CONFIG['BUILD_CTYPES'] and not CONFIG['MOZ_NATIVE_FFI']:
+        add_tier_dir('js', ['js/src/ctypes/libffi'], static=True)
+    add_tier_dir('js', ['intl/icu'], static=True)
+    CONFIGURE_SUBST_FILES += ['intl/icu/Makefile']
+    add_tier_dir('js', ['js/src'])
+
+if not CONFIG['JS_STANDALONE']:
     # Bring in the configuration for the configured application.
     include('/' + CONFIG['MOZ_BUILD_APP'] + '/app.mozbuild')
--- a/python/mozbuild/mozbuild/backend/recursivemake.py
+++ b/python/mozbuild/mozbuild/backend/recursivemake.py
@@ -1102,23 +1102,25 @@ class RecursiveMakeBackend(CommonBackend
         output.
 
         When the stub argument is True, no source file is used, and a stub
         makefile with the default header and footer only is created.
         '''
         with self._get_preprocessor(obj) as pp:
             if extra:
                 pp.context.update(extra)
+            if not pp.context.get('autoconfmk', ''):
+                pp.context['autoconfmk'] = 'autoconf.mk'
             pp.handleLine(b'# THIS FILE WAS AUTOMATICALLY GENERATED. DO NOT MODIFY BY HAND.\n');
             pp.handleLine(b'DEPTH := @DEPTH@\n')
             pp.handleLine(b'topsrcdir := @top_srcdir@\n')
             pp.handleLine(b'srcdir := @srcdir@\n')
             pp.handleLine(b'VPATH := @srcdir@\n')
             pp.handleLine(b'relativesrcdir := @relativesrcdir@\n')
-            pp.handleLine(b'include $(DEPTH)/config/autoconf.mk\n')
+            pp.handleLine(b'include $(DEPTH)/config/@autoconfmk@\n')
             if not stub:
                 pp.do_include(obj.input_path)
             # Empty line to avoid failures when last line in Makefile.in ends
             # with a backslash.
             pp.handleLine(b'\n')
             pp.handleLine(b'include $(topsrcdir)/config/recurse.mk\n')
         if not stub:
             # Adding the Makefile.in here has the desired side-effect
--- a/python/mozbuild/mozbuild/frontend/reader.py
+++ b/python/mozbuild/mozbuild/frontend/reader.py
@@ -164,16 +164,23 @@ class MozbuildSandbox(Sandbox):
                 self.config = config
                 break
 
         self.topsrcdir = topsrcdir
 
         relpath = mozpath.relpath(path, topsrcdir)
         reldir = mozpath.dirname(relpath)
 
+        if mozpath.dirname(relpath) == 'js/src' and \
+                not config.substs.get('JS_STANDALONE'):
+            config = ConfigEnvironment.from_config_status(
+                mozpath.join(topobjdir, reldir, 'config.status'))
+            config.topobjdir = topobjdir
+            self.config = config
+
         with self._globals.allow_all_writes() as d:
             d['TOPSRCDIR'] = topsrcdir
             d['TOPOBJDIR'] = topobjdir
             d['RELATIVEDIR'] = reldir
             d['SRCDIR'] = mozpath.join(topsrcdir, reldir).rstrip('/')
             d['OBJDIR'] = mozpath.join(topobjdir, reldir).rstrip('/')
 
             d['CONFIG'] = ReadOnlyDefaultDict(self.config.substs_unicode,
--- a/testing/testsuite-targets.mk
+++ b/testing/testsuite-targets.mk
@@ -275,17 +275,16 @@ crashtest-ipc:
 crashtest-ipc-gpu: TEST_PATH?=testing/crashtest/crashtests.list
 crashtest-ipc-gpu:
 	$(call RUN_REFTEST,'$(topsrcdir)/$(TEST_PATH)' $(OOP_CONTENT) $(GPU_RENDERING))
 	$(CHECK_TEST_ERROR)
 
 jstestbrowser: TESTS_PATH?=test-package-stage/jsreftest/tests/
 jstestbrowser:
 	$(MAKE) -C $(DEPTH)/config
-	$(MAKE) -C $(DEPTH)/js/src/config
 	$(MAKE) stage-jstests
 	$(call RUN_REFTEST,'$(DIST)/$(TESTS_PATH)/jstests.list' --extra-profile-file=$(DIST)/test-package-stage/jsreftest/tests/user.js)
 	$(CHECK_TEST_ERROR)
 
 GARBAGE += $(addsuffix .log,$(MOCHITESTS) reftest crashtest jstestbrowser)
 
 # Execute all xpcshell tests in the directories listed in the manifest.
 # See also config/rules.mk 'xpcshell-tests' target for local execution.
@@ -456,17 +455,17 @@ endif
 
 stage-reftest: make-stage-dir
 	$(MAKE) -C $(DEPTH)/layout/tools/reftest stage-package
 
 stage-xpcshell: make-stage-dir
 	$(MAKE) -C $(DEPTH)/testing/xpcshell stage-package
 
 stage-jstests: make-stage-dir
-	$(MAKE) -C $(DEPTH)/js/src/js/src/tests stage-package
+	$(MAKE) -C $(DEPTH)/js/src/tests stage-package
 
 stage-android: make-stage-dir
 ifdef MOZ_ENABLE_SZIP
 # Tinderbox scripts are not unzipping everything, so the file needs to be in a directory it unzips
 	$(NSINSTALL) $(DIST)/host/bin/szip $(PKG_STAGE)/bin/host
 endif
 	$(NSINSTALL) $(DEPTH)/build/mobile/sutagent/android/sutAgentAndroid.apk $(PKG_STAGE)/bin
 	$(NSINSTALL) $(DEPTH)/build/mobile/sutagent/android/watcher/Watcher.apk $(PKG_STAGE)/bin
--- a/toolkit/toolkit.mozbuild
+++ b/toolkit/toolkit.mozbuild
@@ -1,27 +1,16 @@
 # vim: set filetype=python:
 # 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/.
 
 if CONFIG['LIBXUL_SDK']:
     error('toolkit.mozbuild is not compatible with --enable-libxul-sdk=')
 
-if CONFIG['COMPILE_ENVIRONMENT']:
-    if not CONFIG['MOZ_NATIVE_NSPR']:
-        add_tier_dir('nspr', 'config/nspr')
-
-    add_tier_dir('external', 'config/external')
-
-    if not CONFIG['MOZ_NATIVE_NSS']:
-        add_tier_dir('nss', 'security/build')
-
-    include('/config/js/js.mozbuild')
-
 if CONFIG['MOZ_CONTENT_SANDBOX']:
     add_tier_dir('sandbox', 'security/sandbox')
 
 # Depends on NSS and NSPR, and must be built after sandbox or else B2G emulator
 # builds fail.
 add_tier_dir('platform', 'security/certverifier')
 
 # the signing related bits of libmar depend on nss