Bug 906101 - Move tier make logic into own .mk file and don't use from rules.mk; r=glandium
authorGregory Szorc <gps@mozilla.com>
Tue, 20 Aug 2013 13:03:39 -0700
changeset 156511 e6ed18f19d793df97c765ca81cb61f6018e97d3b
parent 156510 ef5322627c862593dee45760853feec972e27c4f
child 156512 be5a8c4d2d21a55f22d3b091fd29eb0b14d60c49
push id1
push usersledru@mozilla.com
push dateThu, 04 Dec 2014 17:57:20 +0000
reviewersglandium
bugs906101
milestone26.0a1
Bug 906101 - Move tier make logic into own .mk file and don't use from rules.mk; r=glandium The existing tier traversal logic is only used in the top-level Makefile but was present in rules.mk. This meant it was getting evaluated for every Makefile. This was silly and thus the logic has mostly been moved into its own .mk file and is only included for the root Makefile.
Makefile.in
config/makefiles/target_export.mk
config/makefiles/target_libs.mk
config/makefiles/target_tools.mk
config/makefiles/tiers.mk
config/rules.mk
js/src/config/makefiles/target_export.mk
js/src/config/makefiles/target_libs.mk
js/src/config/makefiles/target_tools.mk
js/src/config/makefiles/tiers.mk
js/src/config/rules.mk
python/mozbuild/mozbuild/backend/recursivemake.py
--- a/Makefile.in
+++ b/Makefile.in
@@ -94,16 +94,23 @@ ifdef ENABLE_TESTS
 include $(topsrcdir)/testing/testsuite-targets.mk
 endif
 
 # Hacky way for precompile tier to bypass default tier traversal mechanism.
 TIER_precompile_CUSTOM := 1
 
 include $(topsrcdir)/config/rules.mk
 
+default all alldep::
+	$(call BUILDSTATUS,TIERS $(TIERS))
+	$(foreach tier,$(TIERS),$(call SUBMAKE,tier_$(tier)))
+
+include $(topsrcdir)/config/makefiles/tiers.mk
+$(foreach tier,$(TIERS),$(eval $(call CREATE_TIER_RULE,$(tier))))
+
 distclean::
 	cat unallmakefiles | $(XARGS) rm -f
 	$(RM) unallmakefiles $(DIST_GARBAGE)
 
 ifeq ($(OS_ARCH),WINNT)
 # we want to copy PDB files on Windows
 MAKE_SYM_STORE_ARGS := -c --vcs-info
 ifdef PDBSTR_PATH
deleted file mode 100644
--- a/config/makefiles/target_export.mk
+++ /dev/null
@@ -1,32 +0,0 @@
-# -*- makefile -*-
-# vim:set ts=8 sw=8 sts=8 noet:
-#
-# 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/.
-
-PARALLEL_DIRS_export = $(addsuffix _export,$(PARALLEL_DIRS))
-
-.PHONY: export $(PARALLEL_DIRS_export)
-
-###############
-## TIER targets
-###############
-$(addprefix export_tier_,$(TIERS)): export_tier_%:
-	@$(ECHO) "$@"
-	$(foreach dir,$(tier_$*_dirs),$(call TIER_DIR_SUBMAKE,$*,export,$(dir),export))
-
-#################
-## Common targets
-#################
-ifdef PARALLEL_DIRS
-export:: $(PARALLEL_DIRS_export)
-
-$(PARALLEL_DIRS_export): %_export: %/Makefile
-	+@$(call SUBMAKE,export,$*)
-endif
-
-export:: $(SUBMAKEFILES) $(MAKE_DIRS)
-	$(LOOP_OVER_DIRS)
-	$(LOOP_OVER_TOOL_DIRS)
-
--- a/config/makefiles/target_libs.mk
+++ b/config/makefiles/target_libs.mk
@@ -1,40 +1,15 @@
 # -*- makefile -*-
 # vim:set ts=8 sw=8 sts=8 noet:
 #
 # 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/.
 
-PARALLEL_DIRS_libs = $(addsuffix _libs,$(PARALLEL_DIRS))
-
-.PHONY: libs $(PARALLEL_DIRS_libs)
-
-###############
-## TIER targets
-###############
-$(addprefix libs_tier_,$(TIERS)): libs_tier_%:
-	@$(ECHO) "$@"
-	$(foreach dir,$(tier_$*_dirs),$(call TIER_DIR_SUBMAKE,$*,libs,$(dir),libs))
-
-#################
-## Common targets
-#################
-ifdef PARALLEL_DIRS
-libs:: $(PARALLEL_DIRS_libs)
-
-$(PARALLEL_DIRS_libs): %_libs: %/Makefile
-	+@$(call SUBMAKE,libs,$*)
-endif
-
-
-####################
-##
-####################
 ifdef EXPORT_LIBRARY
 ifeq ($(EXPORT_LIBRARY),1)
 ifdef IS_COMPONENT
 EXPORT_LIBRARY = $(DEPTH)/staticlib/components
 else
 EXPORT_LIBRARY = $(DEPTH)/staticlib
 endif
 else
deleted file mode 100644
--- a/config/makefiles/target_tools.mk
+++ /dev/null
@@ -1,35 +0,0 @@
-# -*- makefile -*-
-# vim:set ts=8 sw=8 sts=8 noet:
-#
-# 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/.
-
-PARALLEL_DIRS_tools = $(addsuffix _tools,$(PARALLEL_DIRS))
-
-.PHONY: tools $(PARALLEL_DIRS_tools)
-
-###############
-## TIER targets
-###############
-$(addprefix tools_tier_,$(TIERS)): tools_tier_%:
-	@$(ECHO) "$@"
-	$(foreach dir,$(tier_$*_dirs),$(call TIER_DIR_SUBMAKE,$*,tools,$(dir),tools))
-
-#################
-## Common targets
-#################
-ifdef PARALLEL_DIRS
-tools:: $(PARALLEL_DIRS_tools)
-
-$(PARALLEL_DIRS_tools): %_tools: %/Makefile
-	+@$(call SUBMAKE,tools,$*)
-endif
-
-tools:: $(SUBMAKEFILES) $(MAKE_DIRS)
-	$(LOOP_OVER_DIRS)
-ifneq (,$(strip $(TOOL_DIRS)))
-	$(foreach dir,$(TOOL_DIRS),$(call SUBMAKE,libs,$(dir)))
-endif
-
-# EOF
new file mode 100644
--- /dev/null
+++ b/config/makefiles/tiers.mk
@@ -0,0 +1,49 @@
+# -*- makefile -*-
+# vim:set ts=8 sw=8 sts=8 noet:
+#
+# 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/.
+
+# This file contains logic for tier traversal.
+
+define CREATE_SUBTIER_RULE
+$(2)_tier_$(1):
+	$$(call BUILDSTATUS,SUBTIER_START  $(1) $(2) $$(tier_$(1)_dirs))
+	$$(foreach dir,$$(tier_$(1)_dirs),$$(call TIER_DIR_SUBMAKE,$(1),$(2),$$(dir),$(2)))
+	$$(call BUILDSTATUS,SUBTIER_FINISH $(1) $(2))
+
+endef
+
+# This function is called and evaluated to produce the rule to build the
+# specified tier.
+#
+# Tiers are traditionally composed of directories that are invoked either
+# once (so-called "static" directories) or 3 times with the export, libs, and
+# tools sub-tiers.
+#
+# If the TIER_$(tier)_CUSTOM variable is defined, then these traditional
+# tier rules are ignored and each directory in the tier is executed via a
+# sub-make invocation (make -C).
+define CREATE_TIER_RULE
+tier_$(1)::
+ifdef TIER_$(1)_CUSTOM
+	$$(foreach dir,$$($$@_dirs),$$(call SUBMAKE,,$$(dir)))
+else
+	$(call BUILDSTATUS,TIER_START $(1) $(if $(tier_$(1)_staticdirs),static )$(if $(tier_$(1)_dirs),export libs tools))
+ifneq (,$(tier_$(1)_staticdirs))
+	$(call BUILDSTATUS,SUBTIER_START  $(1) static $$($$@_staticdirs))
+	$$(foreach dir,$$($$@_staticdirs),$$(call TIER_DIR_SUBMAKE,$(1),static,$$(dir),,1))
+	$(call BUILDSTATUS,SUBTIER_FINISH $(1) static)
+endif
+ifneq (,$(tier_$(1)_dirs))
+	$$(MAKE) export_$$@
+	$$(MAKE) libs_$$@
+	$$(MAKE) tools_$$@
+endif
+	$(call BUILDSTATUS,TIER_FINISH $(1))
+endif
+
+$(foreach subtier,export libs tools,$(call CREATE_SUBTIER_RULE,$(1),$(subtier)))
+
+endef
--- a/config/rules.mk
+++ b/config/rules.mk
@@ -58,21 +58,16 @@ endif
 # the backend hasn't been properly configured. We want this to be a fatal
 # error, hence not using "-include".
 ifndef STANDALONE_MAKEFILE
 GLOBAL_DEPS += backend.mk
 include backend.mk
 endif
 endif
 
-ifdef TIERS
-DIRS += $(foreach tier,$(TIERS),$(tier_$(tier)_dirs))
-STATIC_DIRS += $(foreach tier,$(TIERS),$(tier_$(tier)_staticdirs))
-endif
-
 ifndef MOZILLA_DIR
 MOZILLA_DIR = $(topsrcdir)
 endif
 
 ifndef INCLUDED_CONFIG_MK
 include $(topsrcdir)/config/config.mk
 endif
 
@@ -675,22 +670,17 @@ endif
 #   This is used to update or create the Makefiles before invoking them.
 SUBMAKEFILES += $(addsuffix /Makefile, $(DIRS) $(TOOL_DIRS) $(PARALLEL_DIRS))
 
 # The root makefile doesn't want to do a plain export/libs, because
 # of the tiers and because of libxul. Suppress the default rules in favor
 # of something else. Makefiles which use this var *must* provide a sensible
 # default rule before including rules.mk
 ifndef SUPPRESS_DEFAULT_RULES
-ifdef TIERS
-default all alldep::
-	$(call BUILDSTATUS,TIERS $(TIERS))
-	$(foreach tier,$(TIERS),$(call SUBMAKE,tier_$(tier)))
-else
-
+ifndef TIERS
 default all::
 ifneq (,$(strip $(STATIC_DIRS)))
 	$(foreach dir,$(STATIC_DIRS),$(call SUBMAKE,,$(dir),1))
 endif
 	$(MAKE) export
 	$(MAKE) libs
 	$(MAKE) tools
 
@@ -707,72 +697,60 @@ endif # SUPPRESS_DEFAULT_RULES
 ifeq ($(findstring s,$(filter-out --%, $(MAKEFLAGS))),)
 ECHO := echo
 QUIET :=
 else
 ECHO := true
 QUIET := -q
 endif
 
-# This function is called and evaluated to produce the rule to build the
-# specified tier.
-#
-# Tiers are traditionally composed of directories that are invoked either
-# once (so-called "static" directories) or 3 times with the export, libs, and
-# tools sub-tiers.
-#
-# If the TIER_$(tier)_CUSTOM variable is defined, then these traditional
-# tier rules are ignored and each directory in the tier is executed via a
-# sub-make invocation (make -C).
-define CREATE_TIER_RULE
-tier_$(1)::
-ifdef TIER_$(1)_CUSTOM
-	$$(foreach dir,$$($$@_dirs),$$(call SUBMAKE,,$$(dir)))
-else
-	$(call BUILDSTATUS,TIER_START $(1) $(if $(tier_$(1)_staticdirs),static )$(if $(tier_$(1)_dirs),export libs tools))
-ifneq (,$(tier_$(1)_staticdirs))
-	$(call BUILDSTATUS,SUBTIER_START  $(1) static $$($$@_staticdirs))
-	$$(foreach dir,$$($$@_staticdirs),$$(call TIER_DIR_SUBMAKE,$(1),static,$$(dir),,1))
-	$(call BUILDSTATUS,SUBTIER_FINISH $(1) static)
-endif
-ifneq (,$(tier_$(1)_dirs))
-	$(call BUILDSTATUS,SUBTIER_START  $(1) export $$($$@_dirs))
-	$$(MAKE) export_$$@
-	$(call BUILDSTATUS,SUBTIER_FINISH $(1) export)
-	$(call BUILDSTATUS,SUBTIER_START  $(1) libs $$($$@_dirs))
-	$$(MAKE) libs_$$@
-	$(call BUILDSTATUS,SUBTIER_FINISH $(1) libs)
-	$(call BUILDSTATUS,SUBTIER_START  $(1) tools $$($$@_dirs))
-	$$(MAKE) tools_$$@
-	$(call BUILDSTATUS,SUBTIER_FINISH $(1) tools)
-endif
-	$(call BUILDSTATUS,TIER_FINISH $(1))
-endif
-endef
-
-$(foreach tier,$(TIERS),$(eval $(call CREATE_TIER_RULE,$(tier))))
-
 # Do everything from scratch
 everything::
 	$(MAKE) clean
 	$(MAKE) alldep
 
 # Add dummy depend target for tinderboxes
 depend::
 
 # Target to only regenerate makefiles
 makefiles: $(SUBMAKEFILES)
 ifneq (,$(DIRS)$(TOOL_DIRS)$(PARALLEL_DIRS))
 	$(LOOP_OVER_PARALLEL_DIRS)
 	$(LOOP_OVER_DIRS)
 	$(LOOP_OVER_TOOL_DIRS)
 endif
 
-include $(topsrcdir)/config/makefiles/target_export.mk
-include $(topsrcdir)/config/makefiles/target_tools.mk
+#########################
+# Tier traversal handling
+#########################
+define CREATE_SUBTIER_TRAVERSAL_RULE
+PARALLEL_DIRS_$(1) = $$(addsuffix _$(1),$$(PARALLEL_DIRS))
+
+.PHONY: $(1) $$(PARALLEL_DIRS_$(1))
+
+ifdef PARALLEL_DIRS
+$(1):: $$(PARALLEL_DIRS_$(1))
+
+$$(PARALLEL_DIRS_$(1)): %_$(1): %/Makefile
+	+@$$(call SUBMAKE,$(1),$$*)
+endif
+
+endef
+
+$(foreach subtier,export libs tools,$(eval $(call CREATE_SUBTIER_TRAVERSAL_RULE,$(subtier))))
+
+export:: $(SUBMAKEFILES) $(MAKE_DIRS)
+	$(LOOP_OVER_DIRS)
+	$(LOOP_OVER_TOOL_DIRS)
+
+
+tools:: $(SUBMAKEFILES) $(MAKE_DIRS)
+	$(LOOP_OVER_DIRS)
+	$(foreach dir,$(TOOL_DIRS),$(call SUBMAKE,libs,$(dir)))
+
 
 ifneq (,$(filter-out %.$(LIB_SUFFIX),$(SHARED_LIBRARY_LIBS)))
 $(error SHARED_LIBRARY_LIBS must contain .$(LIB_SUFFIX) files only)
 endif
 
 HOST_LIBS_DEPS = $(filter %.$(LIB_SUFFIX),$(HOST_LIBS))
 
 # Dependencies which, if modified, should cause everything to rebuild
deleted file mode 100644
--- a/js/src/config/makefiles/target_export.mk
+++ /dev/null
@@ -1,32 +0,0 @@
-# -*- makefile -*-
-# vim:set ts=8 sw=8 sts=8 noet:
-#
-# 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/.
-
-PARALLEL_DIRS_export = $(addsuffix _export,$(PARALLEL_DIRS))
-
-.PHONY: export $(PARALLEL_DIRS_export)
-
-###############
-## TIER targets
-###############
-$(addprefix export_tier_,$(TIERS)): export_tier_%:
-	@$(ECHO) "$@"
-	$(foreach dir,$(tier_$*_dirs),$(call TIER_DIR_SUBMAKE,$*,export,$(dir),export))
-
-#################
-## Common targets
-#################
-ifdef PARALLEL_DIRS
-export:: $(PARALLEL_DIRS_export)
-
-$(PARALLEL_DIRS_export): %_export: %/Makefile
-	+@$(call SUBMAKE,export,$*)
-endif
-
-export:: $(SUBMAKEFILES) $(MAKE_DIRS)
-	$(LOOP_OVER_DIRS)
-	$(LOOP_OVER_TOOL_DIRS)
-
--- a/js/src/config/makefiles/target_libs.mk
+++ b/js/src/config/makefiles/target_libs.mk
@@ -1,40 +1,15 @@
 # -*- makefile -*-
 # vim:set ts=8 sw=8 sts=8 noet:
 #
 # 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/.
 
-PARALLEL_DIRS_libs = $(addsuffix _libs,$(PARALLEL_DIRS))
-
-.PHONY: libs $(PARALLEL_DIRS_libs)
-
-###############
-## TIER targets
-###############
-$(addprefix libs_tier_,$(TIERS)): libs_tier_%:
-	@$(ECHO) "$@"
-	$(foreach dir,$(tier_$*_dirs),$(call TIER_DIR_SUBMAKE,$*,libs,$(dir),libs))
-
-#################
-## Common targets
-#################
-ifdef PARALLEL_DIRS
-libs:: $(PARALLEL_DIRS_libs)
-
-$(PARALLEL_DIRS_libs): %_libs: %/Makefile
-	+@$(call SUBMAKE,libs,$*)
-endif
-
-
-####################
-##
-####################
 ifdef EXPORT_LIBRARY
 ifeq ($(EXPORT_LIBRARY),1)
 ifdef IS_COMPONENT
 EXPORT_LIBRARY = $(DEPTH)/staticlib/components
 else
 EXPORT_LIBRARY = $(DEPTH)/staticlib
 endif
 else
deleted file mode 100644
--- a/js/src/config/makefiles/target_tools.mk
+++ /dev/null
@@ -1,35 +0,0 @@
-# -*- makefile -*-
-# vim:set ts=8 sw=8 sts=8 noet:
-#
-# 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/.
-
-PARALLEL_DIRS_tools = $(addsuffix _tools,$(PARALLEL_DIRS))
-
-.PHONY: tools $(PARALLEL_DIRS_tools)
-
-###############
-## TIER targets
-###############
-$(addprefix tools_tier_,$(TIERS)): tools_tier_%:
-	@$(ECHO) "$@"
-	$(foreach dir,$(tier_$*_dirs),$(call TIER_DIR_SUBMAKE,$*,tools,$(dir),tools))
-
-#################
-## Common targets
-#################
-ifdef PARALLEL_DIRS
-tools:: $(PARALLEL_DIRS_tools)
-
-$(PARALLEL_DIRS_tools): %_tools: %/Makefile
-	+@$(call SUBMAKE,tools,$*)
-endif
-
-tools:: $(SUBMAKEFILES) $(MAKE_DIRS)
-	$(LOOP_OVER_DIRS)
-ifneq (,$(strip $(TOOL_DIRS)))
-	$(foreach dir,$(TOOL_DIRS),$(call SUBMAKE,libs,$(dir)))
-endif
-
-# EOF
new file mode 100644
--- /dev/null
+++ b/js/src/config/makefiles/tiers.mk
@@ -0,0 +1,49 @@
+# -*- makefile -*-
+# vim:set ts=8 sw=8 sts=8 noet:
+#
+# 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/.
+
+# This file contains logic for tier traversal.
+
+define CREATE_SUBTIER_RULE
+$(2)_tier_$(1):
+	$$(call BUILDSTATUS,SUBTIER_START  $(1) $(2) $$(tier_$(1)_dirs))
+	$$(foreach dir,$$(tier_$(1)_dirs),$$(call TIER_DIR_SUBMAKE,$(1),$(2),$$(dir),$(2)))
+	$$(call BUILDSTATUS,SUBTIER_FINISH $(1) $(2))
+
+endef
+
+# This function is called and evaluated to produce the rule to build the
+# specified tier.
+#
+# Tiers are traditionally composed of directories that are invoked either
+# once (so-called "static" directories) or 3 times with the export, libs, and
+# tools sub-tiers.
+#
+# If the TIER_$(tier)_CUSTOM variable is defined, then these traditional
+# tier rules are ignored and each directory in the tier is executed via a
+# sub-make invocation (make -C).
+define CREATE_TIER_RULE
+tier_$(1)::
+ifdef TIER_$(1)_CUSTOM
+	$$(foreach dir,$$($$@_dirs),$$(call SUBMAKE,,$$(dir)))
+else
+	$(call BUILDSTATUS,TIER_START $(1) $(if $(tier_$(1)_staticdirs),static )$(if $(tier_$(1)_dirs),export libs tools))
+ifneq (,$(tier_$(1)_staticdirs))
+	$(call BUILDSTATUS,SUBTIER_START  $(1) static $$($$@_staticdirs))
+	$$(foreach dir,$$($$@_staticdirs),$$(call TIER_DIR_SUBMAKE,$(1),static,$$(dir),,1))
+	$(call BUILDSTATUS,SUBTIER_FINISH $(1) static)
+endif
+ifneq (,$(tier_$(1)_dirs))
+	$$(MAKE) export_$$@
+	$$(MAKE) libs_$$@
+	$$(MAKE) tools_$$@
+endif
+	$(call BUILDSTATUS,TIER_FINISH $(1))
+endif
+
+$(foreach subtier,export libs tools,$(call CREATE_SUBTIER_RULE,$(1),$(subtier)))
+
+endef
--- a/js/src/config/rules.mk
+++ b/js/src/config/rules.mk
@@ -58,21 +58,16 @@ endif
 # the backend hasn't been properly configured. We want this to be a fatal
 # error, hence not using "-include".
 ifndef STANDALONE_MAKEFILE
 GLOBAL_DEPS += backend.mk
 include backend.mk
 endif
 endif
 
-ifdef TIERS
-DIRS += $(foreach tier,$(TIERS),$(tier_$(tier)_dirs))
-STATIC_DIRS += $(foreach tier,$(TIERS),$(tier_$(tier)_staticdirs))
-endif
-
 ifndef MOZILLA_DIR
 MOZILLA_DIR = $(topsrcdir)
 endif
 
 ifndef INCLUDED_CONFIG_MK
 include $(topsrcdir)/config/config.mk
 endif
 
@@ -675,22 +670,17 @@ endif
 #   This is used to update or create the Makefiles before invoking them.
 SUBMAKEFILES += $(addsuffix /Makefile, $(DIRS) $(TOOL_DIRS) $(PARALLEL_DIRS))
 
 # The root makefile doesn't want to do a plain export/libs, because
 # of the tiers and because of libxul. Suppress the default rules in favor
 # of something else. Makefiles which use this var *must* provide a sensible
 # default rule before including rules.mk
 ifndef SUPPRESS_DEFAULT_RULES
-ifdef TIERS
-default all alldep::
-	$(call BUILDSTATUS,TIERS $(TIERS))
-	$(foreach tier,$(TIERS),$(call SUBMAKE,tier_$(tier)))
-else
-
+ifndef TIERS
 default all::
 ifneq (,$(strip $(STATIC_DIRS)))
 	$(foreach dir,$(STATIC_DIRS),$(call SUBMAKE,,$(dir),1))
 endif
 	$(MAKE) export
 	$(MAKE) libs
 	$(MAKE) tools
 
@@ -707,72 +697,60 @@ endif # SUPPRESS_DEFAULT_RULES
 ifeq ($(findstring s,$(filter-out --%, $(MAKEFLAGS))),)
 ECHO := echo
 QUIET :=
 else
 ECHO := true
 QUIET := -q
 endif
 
-# This function is called and evaluated to produce the rule to build the
-# specified tier.
-#
-# Tiers are traditionally composed of directories that are invoked either
-# once (so-called "static" directories) or 3 times with the export, libs, and
-# tools sub-tiers.
-#
-# If the TIER_$(tier)_CUSTOM variable is defined, then these traditional
-# tier rules are ignored and each directory in the tier is executed via a
-# sub-make invocation (make -C).
-define CREATE_TIER_RULE
-tier_$(1)::
-ifdef TIER_$(1)_CUSTOM
-	$$(foreach dir,$$($$@_dirs),$$(call SUBMAKE,,$$(dir)))
-else
-	$(call BUILDSTATUS,TIER_START $(1) $(if $(tier_$(1)_staticdirs),static )$(if $(tier_$(1)_dirs),export libs tools))
-ifneq (,$(tier_$(1)_staticdirs))
-	$(call BUILDSTATUS,SUBTIER_START  $(1) static $$($$@_staticdirs))
-	$$(foreach dir,$$($$@_staticdirs),$$(call TIER_DIR_SUBMAKE,$(1),static,$$(dir),,1))
-	$(call BUILDSTATUS,SUBTIER_FINISH $(1) static)
-endif
-ifneq (,$(tier_$(1)_dirs))
-	$(call BUILDSTATUS,SUBTIER_START  $(1) export $$($$@_dirs))
-	$$(MAKE) export_$$@
-	$(call BUILDSTATUS,SUBTIER_FINISH $(1) export)
-	$(call BUILDSTATUS,SUBTIER_START  $(1) libs $$($$@_dirs))
-	$$(MAKE) libs_$$@
-	$(call BUILDSTATUS,SUBTIER_FINISH $(1) libs)
-	$(call BUILDSTATUS,SUBTIER_START  $(1) tools $$($$@_dirs))
-	$$(MAKE) tools_$$@
-	$(call BUILDSTATUS,SUBTIER_FINISH $(1) tools)
-endif
-	$(call BUILDSTATUS,TIER_FINISH $(1))
-endif
-endef
-
-$(foreach tier,$(TIERS),$(eval $(call CREATE_TIER_RULE,$(tier))))
-
 # Do everything from scratch
 everything::
 	$(MAKE) clean
 	$(MAKE) alldep
 
 # Add dummy depend target for tinderboxes
 depend::
 
 # Target to only regenerate makefiles
 makefiles: $(SUBMAKEFILES)
 ifneq (,$(DIRS)$(TOOL_DIRS)$(PARALLEL_DIRS))
 	$(LOOP_OVER_PARALLEL_DIRS)
 	$(LOOP_OVER_DIRS)
 	$(LOOP_OVER_TOOL_DIRS)
 endif
 
-include $(topsrcdir)/config/makefiles/target_export.mk
-include $(topsrcdir)/config/makefiles/target_tools.mk
+#########################
+# Tier traversal handling
+#########################
+define CREATE_SUBTIER_TRAVERSAL_RULE
+PARALLEL_DIRS_$(1) = $$(addsuffix _$(1),$$(PARALLEL_DIRS))
+
+.PHONY: $(1) $$(PARALLEL_DIRS_$(1))
+
+ifdef PARALLEL_DIRS
+$(1):: $$(PARALLEL_DIRS_$(1))
+
+$$(PARALLEL_DIRS_$(1)): %_$(1): %/Makefile
+	+@$$(call SUBMAKE,$(1),$$*)
+endif
+
+endef
+
+$(foreach subtier,export libs tools,$(eval $(call CREATE_SUBTIER_TRAVERSAL_RULE,$(subtier))))
+
+export:: $(SUBMAKEFILES) $(MAKE_DIRS)
+	$(LOOP_OVER_DIRS)
+	$(LOOP_OVER_TOOL_DIRS)
+
+
+tools:: $(SUBMAKEFILES) $(MAKE_DIRS)
+	$(LOOP_OVER_DIRS)
+	$(foreach dir,$(TOOL_DIRS),$(call SUBMAKE,libs,$(dir)))
+
 
 ifneq (,$(filter-out %.$(LIB_SUFFIX),$(SHARED_LIBRARY_LIBS)))
 $(error SHARED_LIBRARY_LIBS must contain .$(LIB_SUFFIX) files only)
 endif
 
 HOST_LIBS_DEPS = $(filter %.$(LIB_SUFFIX),$(HOST_LIBS))
 
 # Dependencies which, if modified, should cause everything to rebuild
--- a/python/mozbuild/mozbuild/backend/recursivemake.py
+++ b/python/mozbuild/mozbuild/backend/recursivemake.py
@@ -327,21 +327,23 @@ class RecursiveMakeBackend(CommonBackend
         """Process a data.DirectoryTraversal instance."""
         fh = backend_file.fh
 
         for tier, dirs in obj.tier_dirs.iteritems():
             fh.write('TIERS += %s\n' % tier)
 
             if dirs:
                 fh.write('tier_%s_dirs += %s\n' % (tier, ' '.join(dirs)))
+                fh.write('DIRS += $(tier_%s_dirs)\n' % tier)
 
             # tier_static_dirs should have the same keys as tier_dirs.
             if obj.tier_static_dirs[tier]:
                 fh.write('tier_%s_staticdirs += %s\n' % (
                     tier, ' '.join(obj.tier_static_dirs[tier])))
+                fh.write('STATIC_DIRS += $(tier_%s_staticdirs)' % tier)
 
                 static = ' '.join(obj.tier_static_dirs[tier])
                 fh.write('EXTERNAL_DIRS += %s\n' % static)
 
         if obj.dirs:
             fh.write('DIRS := %s\n' % ' '.join(obj.dirs))
 
         if obj.parallel_dirs: