bug 461395 - add support for PARALLEL_DIRS to build system, parallelize content. r=bsmedberg
authorTed Mielczarek <ted.mielczarek@gmail.com>
Thu, 30 Oct 2008 13:02:14 -0400
changeset 21102 80406c10f79550033c169b537db21669d3aef401
parent 21101 deed24924f5a3eb6cf282cc666ae48447ec09b0a
child 21103 c4c01d41e11a5ffb8ea260cdf3490b30589c0073
push id3314
push usertmielczarek@mozilla.com
push dateThu, 30 Oct 2008 17:02:46 +0000
treeherdermozilla-central@80406c10f795 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbsmedberg
bugs461395
milestone1.9.1b2pre
bug 461395 - add support for PARALLEL_DIRS to build system, parallelize content. r=bsmedberg
config/rules.mk
content/Makefile.in
content/base/Makefile.in
content/canvas/Makefile.in
content/events/Makefile.in
content/html/Makefile.in
content/html/content/Makefile.in
content/html/document/Makefile.in
content/media/video/Makefile.in
content/svg/Makefile.in
content/svg/content/Makefile.in
content/xbl/Makefile.in
content/xml/Makefile.in
content/xml/document/Makefile.in
content/xslt/Makefile.in
content/xslt/src/Makefile.in
content/xtf/Makefile.in
content/xul/Makefile.in
content/xul/content/Makefile.in
content/xul/document/Makefile.in
content/xul/templates/Makefile.in
js/src/config/rules.mk
--- a/config/rules.mk
+++ b/config/rules.mk
@@ -360,24 +360,36 @@ ifdef MOZ_UPDATE_XTERM
 # platforms, but we can trick sed into doing it.
 UPDATE_TITLE = sed -e "s!Y!$@ in $(shell $(BUILD_TOOLS)/print-depth-path.sh)/$(dir)!" $(MOZILLA_DIR)/config/xterm.str;
 endif
 
 LOOP_OVER_DIRS = \
     @$(EXIT_ON_ERROR) \
     $(foreach dir,$(DIRS),$(UPDATE_TITLE) $(MAKE) -C $(dir) $@; ) true
 
+# we only use this for the makefiles target and other stuff that doesn't matter
+LOOP_OVER_PARALLEL_DIRS = \
+    @$(EXIT_ON_ERROR) \
+    $(foreach dir,$(PARALLEL_DIRS),$(UPDATE_TITLE) $(MAKE) -C $(dir) $@; ) true
+
 LOOP_OVER_STATIC_DIRS = \
     @$(EXIT_ON_ERROR) \
     $(foreach dir,$(STATIC_DIRS),$(UPDATE_TITLE) $(MAKE) -C $(dir) $@; ) true
 
 LOOP_OVER_TOOL_DIRS = \
     @$(EXIT_ON_ERROR) \
     $(foreach dir,$(TOOL_DIRS),$(UPDATE_TITLE) $(MAKE) -C $(dir) $@; ) true
 
+ifdef PARALLEL_DIRS
+# create a bunch of fake targets for order-only processing
+PARALLEL_DIRS_export = $(addsuffix _export,$(PARALLEL_DIRS))
+PARALLEL_DIRS_libs = $(addsuffix _libs,$(PARALLEL_DIRS))
+PARALLEL_DIRS_tools = $(addsuffix _tools,$(PARALLEL_DIRS))
+endif
+
 #
 # Now we can differentiate between objects used to build a library, and
 # objects used to build an executable in the same directory.
 #
 ifndef PROGOBJS
 PROGOBJS		= $(OBJS)
 endif
 
@@ -577,16 +589,18 @@ HOST_OUTOPTION = -o # eol
 endif
 
 endif
 ################################################################################
 
 # SUBMAKEFILES: List of Makefiles for next level down.
 #   This is used to update or create the Makefiles before invoking them.
 SUBMAKEFILES += $(addsuffix /Makefile, $(DIRS) $(TOOL_DIRS))
+PARALLEL_SUBMAKEFILES += $(addsuffix /Makefile, $(PARALLEL_DIRS))
+SUBMAKEFILES += $(PARALLEL_SUBMAKEFILES)
 
 # The root makefile doesn't want to do a plain export/libs, because
 # of the tiers and because of libxul. Suppress the default rules in favor
 # of something else. Makefiles which use this var *must* provide a sensible
 # default rule before including rules.mk
 ifndef SUPPRESS_DEFAULT_RULES
 ifdef TIERS
 
@@ -672,25 +686,40 @@ all_platforms:: $(NFSPWD)
 	done
 
 $(NFSPWD):
 	cd $(@D); $(MAKE) $(@F)
 endif
 
 # Target to only regenerate makefiles
 makefiles: $(SUBMAKEFILES)
-ifneq (,$(DIRS)$(TOOL_DIRS))
+ifneq (,$(DIRS)$(TOOL_DIRS)$(PARALLEL_DIRS))
+	+$(LOOP_OVER_PARALLEL_DIRS)
 	+$(LOOP_OVER_DIRS)
 	+$(LOOP_OVER_TOOL_DIRS)
 endif
 
+ifdef PARALLEL_DIRS
+export:: $(PARALLEL_SUBMAKEFILES) | $(PARALLEL_DIRS_export)
+
+$(PARALLEL_DIRS_export):: %_export:
+	+$(MAKE) -C $* export
+endif
+
 export:: $(SUBMAKEFILES) $(MAKE_DIRS) $(if $(EXPORTS)$(XPIDLSRCS)$(SDK_HEADERS)$(SDK_XPIDLSRCS),$(PUBLIC)) $(if $(SDK_HEADERS)$(SDK_XPIDLSRCS),$(SDK_PUBLIC)) $(if $(XPIDLSRCS),$(IDL_DIR)) $(if $(SDK_XPIDLSRCS),$(SDK_IDL_DIR))
 	+$(LOOP_OVER_DIRS)
 	+$(LOOP_OVER_TOOL_DIRS)
 
+ifdef PARALLEL_DIRS
+tools:: $(PARALLEL_SUBMAKEFILES) | $(PARALLEL_DIRS_tools)
+
+$(PARALLEL_DIRS_tools):: %_tools:
+	+$(MAKE) -C $* tools
+endif
+
 tools:: $(SUBMAKEFILES) $(MAKE_DIRS)
 	+$(LOOP_OVER_DIRS)
 ifdef TOOL_DIRS
 	@$(EXIT_ON_ERROR) \
 	$(foreach dir,$(TOOL_DIRS),$(UPDATE_TITLE) $(MAKE) -C $(dir) libs; ) true
 endif
 
 #
@@ -713,16 +742,23 @@ endif # EXPORT_LIBRARY
 endif # LIBRARY_NAME
 
 # Create dependencies on static (and shared EXTRA_DSO_LIBS) libraries
 LIBS_DEPS = $(filter %.$(LIB_SUFFIX), $(LIBS))
 HOST_LIBS_DEPS = $(filter %.$(LIB_SUFFIX), $(HOST_LIBS))
 DSO_LDOPTS_DEPS = $(EXTRA_DSO_LIBS) $(filter %.$(LIB_SUFFIX), $(EXTRA_DSO_LDOPTS))
 
 ##############################################
+ifdef PARALLEL_DIRS
+libs:: $(PARALLEL_SUBMAKEFILES) | $(PARALLEL_DIRS_libs)
+
+$(PARALLEL_DIRS_libs):: %_libs:
+	+$(MAKE) -C $* libs
+endif
+
 libs:: $(SUBMAKEFILES) $(MAKE_DIRS) $(HOST_LIBRARY) $(LIBRARY) $(SHARED_LIBRARY) $(IMPORT_LIBRARY) $(HOST_PROGRAM) $(PROGRAM) $(HOST_SIMPLE_PROGRAMS) $(SIMPLE_PROGRAMS) $(JAVA_LIBRARY)
 ifndef NO_DIST_INSTALL
 ifdef LIBRARY
 ifdef EXPORT_LIBRARY # Stage libs that will be linked into a static build
 ifdef IS_COMPONENT
 	$(INSTALL) $(IFLAGS1) $(LIBRARY) $(DEPTH)/staticlib/components
 else
 	$(INSTALL) $(IFLAGS1) $(LIBRARY) $(DEPTH)/staticlib
@@ -820,21 +856,23 @@ run_viewer: $(FINAL_TARGET)/viewer
 	cd $(FINAL_TARGET); \
 	MOZILLA_FIVE_HOME=`pwd` \
 	LD_LIBRARY_PATH=".:$(LIBS_PATH):$$LD_LIBRARY_PATH" \
 	viewer
 
 clean clobber realclean clobber_all:: $(SUBMAKEFILES)
 	-rm -f $(ALL_TRASH)
 	-rm -rf $(ALL_TRASH_DIRS)
+	+-$(LOOP_OVER_PARALLEL_DIRS)
 	+-$(LOOP_OVER_DIRS)
 	+-$(LOOP_OVER_STATIC_DIRS)
 	+-$(LOOP_OVER_TOOL_DIRS)
 
 distclean:: $(SUBMAKEFILES)
+	+-$(LOOP_OVER_PARALLEL_DIRS)
 	+-$(LOOP_OVER_DIRS)
 	+-$(LOOP_OVER_STATIC_DIRS)
 	+-$(LOOP_OVER_TOOL_DIRS)
 	-rm -rf $(ALL_TRASH_DIRS) 
 	-rm -f $(ALL_TRASH)  \
 	Makefile .HSancillary \
 	$(wildcard *.$(OBJ_SUFFIX)) $(wildcard *.ho) $(wildcard host_*.o*) \
 	$(wildcard *.$(LIB_SUFFIX)) $(wildcard *$(DLL_SUFFIX)) \
@@ -1600,16 +1638,17 @@ endif # XPIDLSRCS
 export-idl:: $(SUBMAKEFILES) $(MAKE_DIRS)
 
 ifneq ($(XPIDLSRCS)$(SDK_XPIDLSRCS),)
 ifndef NO_DIST_INSTALL
 export-idl:: $(XPIDLSRCS) $(SDK_XPIDLSRCS) $(IDL_DIR)
 	$(INSTALL) $(IFLAGS1) $^
 endif
 endif
+	+$(LOOP_OVER_PARALLEL_DIRS)
 	+$(LOOP_OVER_DIRS)
 	+$(LOOP_OVER_TOOL_DIRS)
 
 
 
 
 ifneq ($(SDK_XPIDLSRCS),)
 # export .idl files to $(IDL_DIR) & $(SDK_IDL_DIR)
@@ -1746,16 +1785,17 @@ endif # SDK_BINARY
 
 ################################################################################
 # CHROME PACKAGING
 
 JAR_MANIFEST := $(srcdir)/jar.mn
 
 chrome::
 	$(MAKE) realchrome
+	+$(LOOP_OVER_PARALLEL_DIRS)
 	+$(LOOP_OVER_DIRS)
 	+$(LOOP_OVER_TOOL_DIRS)
 
 libs realchrome:: $(CHROME_DEPS)
 ifndef NO_DIST_INSTALL
 	@$(EXIT_ON_ERROR) \
 	if test -f $(JAR_MANIFEST); then \
 	  if test ! -d $(FINAL_TARGET)/chrome; then $(NSINSTALL) -D $(FINAL_TARGET)/chrome; fi; \
@@ -1972,21 +2012,23 @@ endef
 	$(REPORT_BUILD)
 	@$(MAKE_DEPS_NOAUTO)
 
 ifneq (,$(OBJS)$(XPIDLSRCS)$(SDK_XPIDLSRCS)$(SIMPLE_PROGRAMS))
 depend:: $(SUBMAKEFILES) $(MAKE_DIRS) $(MDDEPFILES)
 else
 depend:: $(SUBMAKEFILES)
 endif
+	+$(LOOP_OVER_PARALLEL_DIRS)
 	+$(LOOP_OVER_DIRS)
 	+$(LOOP_OVER_TOOL_DIRS)
 
 dependclean:: $(SUBMAKEFILES)
 	rm -f $(MDDEPFILES)
+	+$(LOOP_OVER_PARALLEL_DIRS)
 	+$(LOOP_OVER_DIRS)
 	+$(LOOP_OVER_TOOL_DIRS)
 
 endif # MOZ_AUTO_DEPS
 
 endif # COMPILER_DEPEND
 
 
@@ -2078,16 +2120,17 @@ FORCE:
 
 # Properly set LIBPATTERNS for the platform
 .LIBPATTERNS = $(if $(IMPORT_LIB_SUFFIX),$(LIB_PREFIX)%.$(IMPORT_LIB_SUFFIX)) $(LIB_PREFIX)%.$(LIB_SUFFIX) $(DLL_PREFIX)%$(DLL_SUFFIX) 
 
 tags: TAGS
 
 TAGS: $(SUBMAKEFILES) $(CSRCS) $(CPPSRCS) $(wildcard *.h)
 	-etags $(CSRCS) $(CPPSRCS) $(wildcard *.h)
+	+$(LOOP_OVER_PARALLEL_DIRS)
 	+$(LOOP_OVER_DIRS)
 
 echo-variable-%:
 	@echo $($*)
 
 echo-tiers:
 	@echo $(TIERS)
 
@@ -2101,16 +2144,17 @@ echo-requires:
 	@echo $(REQUIRES)
 
 echo-requires-recursive::
 ifdef _REPORT_ALL_DIRS
 	@echo $(subst $(topsrcdir)/,,$(srcdir)): $(MODULE): $(REQUIRES)
 else
 	@$(if $(REQUIRES),echo $(subst $(topsrcdir)/,,$(srcdir)): $(MODULE): $(REQUIRES))
 endif
+	+$(LOOP_OVER_PARALLEL_DIRS)
 	+$(LOOP_OVER_DIRS)
 
 echo-depth-path:
 	@$(topsrcdir)/build/unix/print-depth-path.sh
 
 echo-module-name:
 	@$(topsrcdir)/build/package/rpm/print-module-name.sh
 
@@ -2130,16 +2174,17 @@ ifneq (,$(filter $(PROGRAM) $(HOST_PROGR
 	@echo "IMPORT_LIBRARY      = $(IMPORT_LIBRARY)"
 	@echo "STATIC_LIBS         = $(STATIC_LIBS)"
 	@echo "SHARED_LIBS         = $(SHARED_LIBS)"
 	@echo "EXTRA_DSO_LIBS      = $(EXTRA_DSO_LIBS)"
 	@echo "EXTRA_DSO_LDOPTS    = $(EXTRA_DSO_LDOPTS)"
 	@echo "DEPENDENT_LIBS      = $(DEPENDENT_LIBS)"
 	@echo --------------------------------------------------------------------------------
 endif
+	+$(LOOP_OVER_PARALLEL_DIRS)
 	+$(LOOP_OVER_DIRS)
 
 showbuild:
 	@echo "MOZ_BUILD_ROOT     = $(MOZ_BUILD_ROOT)"
 	@echo "MOZ_WIDGET_TOOLKIT = $(MOZ_WIDGET_TOOLKIT)"
 	@echo "CC                 = $(CC)"
 	@echo "CXX                = $(CXX)"
 	@echo "CCC                = $(CCC)"
@@ -2191,17 +2236,19 @@ showhost:
 showbuildmods::
 	@echo "Build Modules	= $(BUILD_MODULES)"
 	@echo "Module dirs	= $(BUILD_MODULE_DIRS)"
 
 zipmakes:
 ifneq (,$(filter $(PROGRAM) $(SIMPLE_PROGRAMS) $(LIBRARY) $(SHARED_LIBRARY),$(TARGETS)))
 	zip $(DEPTH)/makefiles $(subst $(topsrcdir),$(MOZ_SRC)/mozilla,$(srcdir)/Makefile.in)
 endif
+	+$(LOOP_OVER_PARALLEL_DIRS)
 	+$(LOOP_OVER_DIRS)
 
 documentation:
 	@cd $(DEPTH)
 	$(DOXYGEN) $(DEPTH)/config/doxygen.cfg
 
 check:: $(SUBMAKEFILES) $(MAKE_DIRS)
+	+$(LOOP_OVER_PARALLEL_DIRS)
 	+$(LOOP_OVER_DIRS)
 	+$(LOOP_OVER_TOOL_DIRS)
--- a/content/Makefile.in
+++ b/content/Makefile.in
@@ -38,37 +38,37 @@
 DEPTH		= ..
 topsrcdir	= @top_srcdir@
 srcdir		= @srcdir@
 VPATH		= @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
 MODULE		= content
-DIRS		= base canvas html xml xul xbl xslt
+PARALLEL_DIRS		= base canvas html xml xul xbl xslt
 
 ifdef MOZ_MEDIA
-DIRS		+= \
+PARALLEL_DIRS	+= \
 		media \
 		$(NULL)
 endif
 
 ifdef MOZ_SVG
-DIRS		+= svg
+PARALLEL_DIRS	+= svg
 endif
 
 ifdef MOZ_XTF
-DIRS            += xtf
+PARALLEL_DIRS   += xtf
 endif
 
 ifdef MOZ_MATHML
-DIRS            += mathml
+PARALLEL_DIRS   += mathml
 endif
 
-DIRS           += events
+PARALLEL_DIRS   += events
 
 ifdef ENABLE_TESTS
 TOOL_DIRS += test
 endif
 
 # Prevent floating point errors caused by VC++ optimizations
 ifeq ($(OS_ARCH)_$(GNU_CC),WINNT_)
 ifeq (,$(filter-out 1200 1300 1310,$(_MSC_VER)))
--- a/content/base/Makefile.in
+++ b/content/base/Makefile.in
@@ -37,16 +37,16 @@
 
 DEPTH		= ../..
 topsrcdir	= @top_srcdir@
 srcdir		= @srcdir@
 VPATH		= @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
-DIRS		= public src
+PARALLEL_DIRS	= public src
 
 ifdef ENABLE_TESTS
 TOOL_DIRS		+= test
 endif
 
 include $(topsrcdir)/config/rules.mk
 
--- a/content/canvas/Makefile.in
+++ b/content/canvas/Makefile.in
@@ -38,16 +38,16 @@
 
 DEPTH		= ../..
 topsrcdir	= @top_srcdir@
 srcdir		= @srcdir@
 VPATH		= @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
-DIRS		= public src
+PARALLEL_DIRS	= public src
 
 ifdef ENABLE_TESTS
 DIRS		+= test
 endif
 
 include $(topsrcdir)/config/rules.mk
 
--- a/content/events/Makefile.in
+++ b/content/events/Makefile.in
@@ -37,16 +37,16 @@
 
 DEPTH		= ../..
 topsrcdir	= @top_srcdir@
 srcdir		= @srcdir@
 VPATH		= @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
-DIRS		= public src
+PARALLEL_DIRS	= public src
 
 ifdef ENABLE_TESTS
 DIRS		+= test
 endif
 
 include $(topsrcdir)/config/rules.mk
 
--- a/content/html/Makefile.in
+++ b/content/html/Makefile.in
@@ -37,11 +37,11 @@
 
 DEPTH		= ../..
 topsrcdir	= @top_srcdir@
 srcdir		= @srcdir@
 VPATH		= @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
-DIRS		= content document
+PARALLEL_DIRS	= content document
 
 include $(topsrcdir)/config/rules.mk
--- a/content/html/content/Makefile.in
+++ b/content/html/content/Makefile.in
@@ -37,16 +37,16 @@
 
 DEPTH		= ../../..
 topsrcdir	= @top_srcdir@
 srcdir		= @srcdir@
 VPATH		= @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
-DIRS		= public src
+PARALLEL_DIRS	= public src
 
 ifdef ENABLE_TESTS
 DIRS		+= test
 endif
 
 include $(topsrcdir)/config/rules.mk
 
--- a/content/html/document/Makefile.in
+++ b/content/html/document/Makefile.in
@@ -37,16 +37,16 @@
 
 DEPTH		= ../../..
 topsrcdir	= @top_srcdir@
 srcdir		= @srcdir@
 VPATH		= @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
-DIRS		= public src
+PARALLEL_DIRS	= public src
 
 ifdef ENABLE_TESTS
 DIRS		+= test
 endif
 
 include $(topsrcdir)/config/rules.mk
 
--- a/content/media/video/Makefile.in
+++ b/content/media/video/Makefile.in
@@ -36,17 +36,17 @@
 
 DEPTH		= ../../..
 topsrcdir	= @top_srcdir@
 srcdir		= @srcdir@
 VPATH		= @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
-DIRS		= \
+PARALLEL_DIRS	= \
 		public \
 		src \
 		$(NULL)
 
 ifdef ENABLE_TESTS
 DIRS            += test
 endif
 
--- a/content/svg/Makefile.in
+++ b/content/svg/Makefile.in
@@ -37,11 +37,11 @@
 
 DEPTH		= ../..
 topsrcdir	= @top_srcdir@
 srcdir		= @srcdir@
 VPATH		= @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
-DIRS		= document content
+PARALLEL_DIRS	= document content
 
 include $(topsrcdir)/config/rules.mk
--- a/content/svg/content/Makefile.in
+++ b/content/svg/content/Makefile.in
@@ -38,16 +38,16 @@
 
 DEPTH		= ../../..
 topsrcdir	= @top_srcdir@
 srcdir		= @srcdir@
 VPATH		= @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
-DIRS		= src
+PARALLEL_DIRS		= src
 
 ifdef ENABLE_TESTS
 DIRS += test
 endif
 
 include $(topsrcdir)/config/rules.mk
 
--- a/content/xbl/Makefile.in
+++ b/content/xbl/Makefile.in
@@ -37,15 +37,15 @@
 
 DEPTH		= ../..
 topsrcdir	= @top_srcdir@
 srcdir		= @srcdir@
 VPATH		= @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
-DIRS		= public src builtin
+PARALLEL_DIRS	= public src builtin
 
 ifdef ENABLE_TESTS
 DIRS		+= test
 endif
 
 include $(topsrcdir)/config/rules.mk
--- a/content/xml/Makefile.in
+++ b/content/xml/Makefile.in
@@ -37,12 +37,12 @@
 
 DEPTH		= ../..
 topsrcdir	= @top_srcdir@
 srcdir		= @srcdir@
 VPATH		= @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
-DIRS		= content document
+PARALLEL_DIRS	= content document
 
 include $(topsrcdir)/config/rules.mk
 
--- a/content/xml/document/Makefile.in
+++ b/content/xml/document/Makefile.in
@@ -37,16 +37,16 @@
 
 DEPTH		= ../../..
 topsrcdir	= @top_srcdir@
 srcdir		= @srcdir@
 VPATH		= @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
-DIRS		= public resources src
+PARALLEL_DIRS	= public resources src
 
 ifdef ENABLE_TESTS
 DIRS            += test
 endif
 
 include $(topsrcdir)/config/rules.mk
 
--- a/content/xslt/Makefile.in
+++ b/content/xslt/Makefile.in
@@ -37,16 +37,16 @@
 
 DEPTH = ../..
 topsrcdir	= @top_srcdir@
 srcdir		= @srcdir@
 VPATH		= @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
-DIRS = public src
+PARALLEL_DIRS = public src
 
 ifdef ENABLE_TESTS
 DIRS += tests/buster \
 	tests/mochitest
 endif
 
 include $(topsrcdir)/config/rules.mk
--- a/content/xslt/src/Makefile.in
+++ b/content/xslt/src/Makefile.in
@@ -37,15 +37,15 @@
 
 DEPTH           = ../../..
 topsrcdir       = @top_srcdir@
 srcdir          = @srcdir@
 VPATH           = @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
-DIRS            = base xml xpath xslt 
+PARALLEL_DIRS   = base xml xpath xslt 
 
 ifdef MOZ_XSLT_STANDALONE
-DIRS += main
+PARALLEL_DIRS += main
 endif
 
 include $(topsrcdir)/config/rules.mk
--- a/content/xtf/Makefile.in
+++ b/content/xtf/Makefile.in
@@ -37,15 +37,15 @@
 
 DEPTH		= ../..
 topsrcdir	= @top_srcdir@
 srcdir		= @srcdir@
 VPATH		= @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
-DIRS		=  public src
+PARALLEL_DIRS	=  public src
 
 ifdef ENABLE_TESTS
 DIRS  += test
 endif
 
 include $(topsrcdir)/config/rules.mk
--- a/content/xul/Makefile.in
+++ b/content/xul/Makefile.in
@@ -41,16 +41,16 @@ srcdir		= @srcdir@
 VPATH		= @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
 # We need to build document even if XUL is disabled, for the nsIController[s]
 # interfaces and implementations.
 # Likewise for content, because of nsXULAtoms.
 
-DIRS		= document content
+PARALLEL_DIRS	= document content
 
 ifdef MOZ_XUL
-DIRS		+= templates
+PARALLEL_DIRS	+= templates
 endif
 
 include $(topsrcdir)/config/rules.mk
 
--- a/content/xul/content/Makefile.in
+++ b/content/xul/content/Makefile.in
@@ -38,12 +38,12 @@
 DEPTH		= ../../..
 topsrcdir	= @top_srcdir@
 srcdir		= @srcdir@
 VPATH		= @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
 MODULE		= xul
-DIRS		= src test
+PARALLEL_DIRS	= src test
 
 include $(topsrcdir)/config/rules.mk
 
--- a/content/xul/document/Makefile.in
+++ b/content/xul/document/Makefile.in
@@ -38,16 +38,16 @@
 DEPTH		= ../../..
 topsrcdir	= @top_srcdir@
 srcdir		= @srcdir@
 VPATH		= @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
 MODULE		= xuldoc
-DIRS		= public src
+PARALLEL_DIRS	= public src
 
 ifdef ENABLE_TESTS
 DIRS		+= test
 endif
 
 include $(topsrcdir)/config/rules.mk
 
--- a/content/xul/templates/Makefile.in
+++ b/content/xul/templates/Makefile.in
@@ -38,12 +38,12 @@
 DEPTH		= ../../..
 topsrcdir	= @top_srcdir@
 srcdir		= @srcdir@
 VPATH		= @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
 MODULE		= xultmpl
-DIRS		= public src
+PARALLEL_DIRS	= public src
 
 include $(topsrcdir)/config/rules.mk
 
--- a/js/src/config/rules.mk
+++ b/js/src/config/rules.mk
@@ -360,24 +360,36 @@ ifdef MOZ_UPDATE_XTERM
 # platforms, but we can trick sed into doing it.
 UPDATE_TITLE = sed -e "s!Y!$@ in $(shell $(BUILD_TOOLS)/print-depth-path.sh)/$(dir)!" $(MOZILLA_DIR)/config/xterm.str;
 endif
 
 LOOP_OVER_DIRS = \
     @$(EXIT_ON_ERROR) \
     $(foreach dir,$(DIRS),$(UPDATE_TITLE) $(MAKE) -C $(dir) $@; ) true
 
+# we only use this for the makefiles target and other stuff that doesn't matter
+LOOP_OVER_PARALLEL_DIRS = \
+    @$(EXIT_ON_ERROR) \
+    $(foreach dir,$(PARALLEL_DIRS),$(UPDATE_TITLE) $(MAKE) -C $(dir) $@; ) true
+
 LOOP_OVER_STATIC_DIRS = \
     @$(EXIT_ON_ERROR) \
     $(foreach dir,$(STATIC_DIRS),$(UPDATE_TITLE) $(MAKE) -C $(dir) $@; ) true
 
 LOOP_OVER_TOOL_DIRS = \
     @$(EXIT_ON_ERROR) \
     $(foreach dir,$(TOOL_DIRS),$(UPDATE_TITLE) $(MAKE) -C $(dir) $@; ) true
 
+ifdef PARALLEL_DIRS
+# create a bunch of fake targets for order-only processing
+PARALLEL_DIRS_export = $(addsuffix _export,$(PARALLEL_DIRS))
+PARALLEL_DIRS_libs = $(addsuffix _libs,$(PARALLEL_DIRS))
+PARALLEL_DIRS_tools = $(addsuffix _tools,$(PARALLEL_DIRS))
+endif
+
 #
 # Now we can differentiate between objects used to build a library, and
 # objects used to build an executable in the same directory.
 #
 ifndef PROGOBJS
 PROGOBJS		= $(OBJS)
 endif
 
@@ -577,16 +589,18 @@ HOST_OUTOPTION = -o # eol
 endif
 
 endif
 ################################################################################
 
 # SUBMAKEFILES: List of Makefiles for next level down.
 #   This is used to update or create the Makefiles before invoking them.
 SUBMAKEFILES += $(addsuffix /Makefile, $(DIRS) $(TOOL_DIRS))
+PARALLEL_SUBMAKEFILES += $(addsuffix /Makefile, $(PARALLEL_DIRS))
+SUBMAKEFILES += $(PARALLEL_SUBMAKEFILES)
 
 # The root makefile doesn't want to do a plain export/libs, because
 # of the tiers and because of libxul. Suppress the default rules in favor
 # of something else. Makefiles which use this var *must* provide a sensible
 # default rule before including rules.mk
 ifndef SUPPRESS_DEFAULT_RULES
 ifdef TIERS
 
@@ -672,25 +686,40 @@ all_platforms:: $(NFSPWD)
 	done
 
 $(NFSPWD):
 	cd $(@D); $(MAKE) $(@F)
 endif
 
 # Target to only regenerate makefiles
 makefiles: $(SUBMAKEFILES)
-ifneq (,$(DIRS)$(TOOL_DIRS))
+ifneq (,$(DIRS)$(TOOL_DIRS)$(PARALLEL_DIRS))
+	+$(LOOP_OVER_PARALLEL_DIRS)
 	+$(LOOP_OVER_DIRS)
 	+$(LOOP_OVER_TOOL_DIRS)
 endif
 
+ifdef PARALLEL_DIRS
+export:: $(PARALLEL_SUBMAKEFILES) | $(PARALLEL_DIRS_export)
+
+$(PARALLEL_DIRS_export):: %_export:
+	+$(MAKE) -C $* export
+endif
+
 export:: $(SUBMAKEFILES) $(MAKE_DIRS) $(if $(EXPORTS)$(XPIDLSRCS)$(SDK_HEADERS)$(SDK_XPIDLSRCS),$(PUBLIC)) $(if $(SDK_HEADERS)$(SDK_XPIDLSRCS),$(SDK_PUBLIC)) $(if $(XPIDLSRCS),$(IDL_DIR)) $(if $(SDK_XPIDLSRCS),$(SDK_IDL_DIR))
 	+$(LOOP_OVER_DIRS)
 	+$(LOOP_OVER_TOOL_DIRS)
 
+ifdef PARALLEL_DIRS
+tools:: $(PARALLEL_SUBMAKEFILES) | $(PARALLEL_DIRS_tools)
+
+$(PARALLEL_DIRS_tools):: %_tools:
+	+$(MAKE) -C $* tools
+endif
+
 tools:: $(SUBMAKEFILES) $(MAKE_DIRS)
 	+$(LOOP_OVER_DIRS)
 ifdef TOOL_DIRS
 	@$(EXIT_ON_ERROR) \
 	$(foreach dir,$(TOOL_DIRS),$(UPDATE_TITLE) $(MAKE) -C $(dir) libs; ) true
 endif
 
 #
@@ -713,16 +742,23 @@ endif # EXPORT_LIBRARY
 endif # LIBRARY_NAME
 
 # Create dependencies on static (and shared EXTRA_DSO_LIBS) libraries
 LIBS_DEPS = $(filter %.$(LIB_SUFFIX), $(LIBS))
 HOST_LIBS_DEPS = $(filter %.$(LIB_SUFFIX), $(HOST_LIBS))
 DSO_LDOPTS_DEPS = $(EXTRA_DSO_LIBS) $(filter %.$(LIB_SUFFIX), $(EXTRA_DSO_LDOPTS))
 
 ##############################################
+ifdef PARALLEL_DIRS
+libs:: $(PARALLEL_SUBMAKEFILES) | $(PARALLEL_DIRS_libs)
+
+$(PARALLEL_DIRS_libs):: %_libs:
+	+$(MAKE) -C $* libs
+endif
+
 libs:: $(SUBMAKEFILES) $(MAKE_DIRS) $(HOST_LIBRARY) $(LIBRARY) $(SHARED_LIBRARY) $(IMPORT_LIBRARY) $(HOST_PROGRAM) $(PROGRAM) $(HOST_SIMPLE_PROGRAMS) $(SIMPLE_PROGRAMS) $(JAVA_LIBRARY)
 ifndef NO_DIST_INSTALL
 ifdef LIBRARY
 ifdef EXPORT_LIBRARY # Stage libs that will be linked into a static build
 ifdef IS_COMPONENT
 	$(INSTALL) $(IFLAGS1) $(LIBRARY) $(DEPTH)/staticlib/components
 else
 	$(INSTALL) $(IFLAGS1) $(LIBRARY) $(DEPTH)/staticlib
@@ -820,21 +856,23 @@ run_viewer: $(FINAL_TARGET)/viewer
 	cd $(FINAL_TARGET); \
 	MOZILLA_FIVE_HOME=`pwd` \
 	LD_LIBRARY_PATH=".:$(LIBS_PATH):$$LD_LIBRARY_PATH" \
 	viewer
 
 clean clobber realclean clobber_all:: $(SUBMAKEFILES)
 	-rm -f $(ALL_TRASH)
 	-rm -rf $(ALL_TRASH_DIRS)
+	+-$(LOOP_OVER_PARALLEL_DIRS)
 	+-$(LOOP_OVER_DIRS)
 	+-$(LOOP_OVER_STATIC_DIRS)
 	+-$(LOOP_OVER_TOOL_DIRS)
 
 distclean:: $(SUBMAKEFILES)
+	+-$(LOOP_OVER_PARALLEL_DIRS)
 	+-$(LOOP_OVER_DIRS)
 	+-$(LOOP_OVER_STATIC_DIRS)
 	+-$(LOOP_OVER_TOOL_DIRS)
 	-rm -rf $(ALL_TRASH_DIRS) 
 	-rm -f $(ALL_TRASH)  \
 	Makefile .HSancillary \
 	$(wildcard *.$(OBJ_SUFFIX)) $(wildcard *.ho) $(wildcard host_*.o*) \
 	$(wildcard *.$(LIB_SUFFIX)) $(wildcard *$(DLL_SUFFIX)) \
@@ -1600,16 +1638,17 @@ endif # XPIDLSRCS
 export-idl:: $(SUBMAKEFILES) $(MAKE_DIRS)
 
 ifneq ($(XPIDLSRCS)$(SDK_XPIDLSRCS),)
 ifndef NO_DIST_INSTALL
 export-idl:: $(XPIDLSRCS) $(SDK_XPIDLSRCS) $(IDL_DIR)
 	$(INSTALL) $(IFLAGS1) $^
 endif
 endif
+	+$(LOOP_OVER_PARALLEL_DIRS)
 	+$(LOOP_OVER_DIRS)
 	+$(LOOP_OVER_TOOL_DIRS)
 
 
 
 
 ifneq ($(SDK_XPIDLSRCS),)
 # export .idl files to $(IDL_DIR) & $(SDK_IDL_DIR)
@@ -1746,16 +1785,17 @@ endif # SDK_BINARY
 
 ################################################################################
 # CHROME PACKAGING
 
 JAR_MANIFEST := $(srcdir)/jar.mn
 
 chrome::
 	$(MAKE) realchrome
+	+$(LOOP_OVER_PARALLEL_DIRS)
 	+$(LOOP_OVER_DIRS)
 	+$(LOOP_OVER_TOOL_DIRS)
 
 libs realchrome:: $(CHROME_DEPS)
 ifndef NO_DIST_INSTALL
 	@$(EXIT_ON_ERROR) \
 	if test -f $(JAR_MANIFEST); then \
 	  if test ! -d $(FINAL_TARGET)/chrome; then $(NSINSTALL) -D $(FINAL_TARGET)/chrome; fi; \
@@ -1972,21 +2012,23 @@ endef
 	$(REPORT_BUILD)
 	@$(MAKE_DEPS_NOAUTO)
 
 ifneq (,$(OBJS)$(XPIDLSRCS)$(SDK_XPIDLSRCS)$(SIMPLE_PROGRAMS))
 depend:: $(SUBMAKEFILES) $(MAKE_DIRS) $(MDDEPFILES)
 else
 depend:: $(SUBMAKEFILES)
 endif
+	+$(LOOP_OVER_PARALLEL_DIRS)
 	+$(LOOP_OVER_DIRS)
 	+$(LOOP_OVER_TOOL_DIRS)
 
 dependclean:: $(SUBMAKEFILES)
 	rm -f $(MDDEPFILES)
+	+$(LOOP_OVER_PARALLEL_DIRS)
 	+$(LOOP_OVER_DIRS)
 	+$(LOOP_OVER_TOOL_DIRS)
 
 endif # MOZ_AUTO_DEPS
 
 endif # COMPILER_DEPEND
 
 
@@ -2078,16 +2120,17 @@ FORCE:
 
 # Properly set LIBPATTERNS for the platform
 .LIBPATTERNS = $(if $(IMPORT_LIB_SUFFIX),$(LIB_PREFIX)%.$(IMPORT_LIB_SUFFIX)) $(LIB_PREFIX)%.$(LIB_SUFFIX) $(DLL_PREFIX)%$(DLL_SUFFIX) 
 
 tags: TAGS
 
 TAGS: $(SUBMAKEFILES) $(CSRCS) $(CPPSRCS) $(wildcard *.h)
 	-etags $(CSRCS) $(CPPSRCS) $(wildcard *.h)
+	+$(LOOP_OVER_PARALLEL_DIRS)
 	+$(LOOP_OVER_DIRS)
 
 echo-variable-%:
 	@echo $($*)
 
 echo-tiers:
 	@echo $(TIERS)
 
@@ -2101,16 +2144,17 @@ echo-requires:
 	@echo $(REQUIRES)
 
 echo-requires-recursive::
 ifdef _REPORT_ALL_DIRS
 	@echo $(subst $(topsrcdir)/,,$(srcdir)): $(MODULE): $(REQUIRES)
 else
 	@$(if $(REQUIRES),echo $(subst $(topsrcdir)/,,$(srcdir)): $(MODULE): $(REQUIRES))
 endif
+	+$(LOOP_OVER_PARALLEL_DIRS)
 	+$(LOOP_OVER_DIRS)
 
 echo-depth-path:
 	@$(topsrcdir)/build/unix/print-depth-path.sh
 
 echo-module-name:
 	@$(topsrcdir)/build/package/rpm/print-module-name.sh
 
@@ -2130,16 +2174,17 @@ ifneq (,$(filter $(PROGRAM) $(HOST_PROGR
 	@echo "IMPORT_LIBRARY      = $(IMPORT_LIBRARY)"
 	@echo "STATIC_LIBS         = $(STATIC_LIBS)"
 	@echo "SHARED_LIBS         = $(SHARED_LIBS)"
 	@echo "EXTRA_DSO_LIBS      = $(EXTRA_DSO_LIBS)"
 	@echo "EXTRA_DSO_LDOPTS    = $(EXTRA_DSO_LDOPTS)"
 	@echo "DEPENDENT_LIBS      = $(DEPENDENT_LIBS)"
 	@echo --------------------------------------------------------------------------------
 endif
+	+$(LOOP_OVER_PARALLEL_DIRS)
 	+$(LOOP_OVER_DIRS)
 
 showbuild:
 	@echo "MOZ_BUILD_ROOT     = $(MOZ_BUILD_ROOT)"
 	@echo "MOZ_WIDGET_TOOLKIT = $(MOZ_WIDGET_TOOLKIT)"
 	@echo "CC                 = $(CC)"
 	@echo "CXX                = $(CXX)"
 	@echo "CCC                = $(CCC)"
@@ -2191,17 +2236,19 @@ showhost:
 showbuildmods::
 	@echo "Build Modules	= $(BUILD_MODULES)"
 	@echo "Module dirs	= $(BUILD_MODULE_DIRS)"
 
 zipmakes:
 ifneq (,$(filter $(PROGRAM) $(SIMPLE_PROGRAMS) $(LIBRARY) $(SHARED_LIBRARY),$(TARGETS)))
 	zip $(DEPTH)/makefiles $(subst $(topsrcdir),$(MOZ_SRC)/mozilla,$(srcdir)/Makefile.in)
 endif
+	+$(LOOP_OVER_PARALLEL_DIRS)
 	+$(LOOP_OVER_DIRS)
 
 documentation:
 	@cd $(DEPTH)
 	$(DOXYGEN) $(DEPTH)/config/doxygen.cfg
 
 check:: $(SUBMAKEFILES) $(MAKE_DIRS)
+	+$(LOOP_OVER_PARALLEL_DIRS)
 	+$(LOOP_OVER_DIRS)
 	+$(LOOP_OVER_TOOL_DIRS)