bug 742391: split config/rules.mk - file batch #1
authorJoey Armstrong <joey@mozilla.com>
Wed, 16 May 2012 14:46:28 -0400
changeset 95593 98ca9bd48170aac6a183a165a57b28f05a41b4f5
parent 95592 95def0230d0cdff26a9c4eb8d9be20127269e3b6
child 95594 9fdd1e53e1d06c28618b75af19784d2578eadd96
push idunknown
push userunknown
push dateunknown
bugs742391
milestone15.0a1
bug 742391: split config/rules.mk - file batch #1
config/makefiles/debugmake.mk
config/makefiles/makeutils.mk
config/makefiles/test/check_XinY.mk
config/makefiles/xpcshell.mk
config/rules.mk
js/src/config/makefiles/debugmake.mk
js/src/config/makefiles/makeutils.mk
js/src/config/makefiles/xpcshell.mk
js/src/config/rules.mk
new file mode 100644
--- /dev/null
+++ b/config/makefiles/debugmake.mk
@@ -0,0 +1,118 @@
+# -*- 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/.
+#
+
+###########################################################################
+## Intent: Helper targets for displaying variables and state information
+###########################################################################
+
+# Support usage outside of config/rules.mk
+ifndef INCLUDED_DEBUGMAKE_MK #{
+
+echo-variable-%:
+	@echo "$($*)"
+
+echo-tiers:
+	@echo $(TIERS)
+
+echo-tier-dirs:
+	@$(foreach tier,$(TIERS),echo '$(tier):'; echo '  dirs: $(tier_$(tier)_dirs)'; echo '  staticdirs: $(tier_$(tier)_staticdirs)'; )
+
+echo-dirs:
+	@echo $(DIRS)
+
+echo-module:
+	@echo $(MODULE)
+
+echo-depth-path:
+	@$(topsrcdir)/build/unix/print-depth-path.sh
+
+echo-module-name:
+	@$(topsrcdir)/build/package/rpm/print-module-name.sh
+
+echo-module-filelist:
+	@$(topsrcdir)/build/package/rpm/print-module-filelist.sh
+
+showtargs:
+ifneq (,$(filter $(PROGRAM) $(HOST_PROGRAM) $(SIMPLE_PROGRAMS) $(HOST_LIBRARY) $(LIBRARY) $(SHARED_LIBRARY),$(TARGETS)))
+	@echo --------------------------------------------------------------------------------
+	@echo "PROGRAM             = $(PROGRAM)"
+	@echo "SIMPLE_PROGRAMS     = $(SIMPLE_PROGRAMS)"
+	@echo "LIBRARY             = $(LIBRARY)"
+	@echo "SHARED_LIBRARY      = $(SHARED_LIBRARY)"
+	@echo "SHARED_LIBRARY_LIBS = $(SHARED_LIBRARY_LIBS)"
+	@echo "LIBS                = $(LIBS)"
+	@echo "DEF_FILE            = $(DEF_FILE)"
+	@echo "IMPORT_LIBRARY      = $(IMPORT_LIBRARY)"
+	@echo "STATIC_LIBS         = $(STATIC_LIBS)"
+	@echo "SHARED_LIBS         = $(SHARED_LIBS)"
+	@echo "EXTRA_DSO_LIBS      = $(EXTRA_DSO_LIBS)"
+	@echo "EXTRA_DSO_LDOPTS    = $(EXTRA_DSO_LDOPTS)"
+	@echo "DEPENDENT_LIBS      = $(DEPENDENT_LIBS)"
+	@echo --------------------------------------------------------------------------------
+endif
+	$(LOOP_OVER_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)"
+	@echo "CPP                = $(CPP)"
+	@echo "LD                 = $(LD)"
+	@echo "AR                 = $(AR)"
+	@echo "IMPLIB             = $(IMPLIB)"
+	@echo "FILTER             = $(FILTER)"
+	@echo "MKSHLIB            = $(MKSHLIB)"
+	@echo "MKCSHLIB           = $(MKCSHLIB)"
+	@echo "RC                 = $(RC)"
+	@echo "MC                 = $(MC)"
+	@echo "CFLAGS             = $(CFLAGS)"
+	@echo "OS_CFLAGS          = $(OS_CFLAGS)"
+	@echo "COMPILE_CFLAGS     = $(COMPILE_CFLAGS)"
+	@echo "CXXFLAGS           = $(CXXFLAGS)"
+	@echo "OS_CXXFLAGS        = $(OS_CXXFLAGS)"
+	@echo "COMPILE_CXXFLAGS   = $(COMPILE_CXXFLAGS)"
+	@echo "COMPILE_CMFLAGS    = $(COMPILE_CMFLAGS)"
+	@echo "COMPILE_CMMFLAGS   = $(COMPILE_CMMFLAGS)"
+	@echo "LDFLAGS            = $(LDFLAGS)"
+	@echo "OS_LDFLAGS         = $(OS_LDFLAGS)"
+	@echo "DSO_LDOPTS         = $(DSO_LDOPTS)"
+	@echo "OS_INCLUDES        = $(OS_INCLUDES)"
+	@echo "OS_LIBS            = $(OS_LIBS)"
+	@echo "EXTRA_LIBS         = $(EXTRA_LIBS)"
+	@echo "BIN_FLAGS          = $(BIN_FLAGS)"
+	@echo "INCLUDES           = $(INCLUDES)"
+	@echo "DEFINES            = $(DEFINES)"
+	@echo "ACDEFINES          = $(ACDEFINES)"
+	@echo "BIN_SUFFIX         = $(BIN_SUFFIX)"
+	@echo "LIB_SUFFIX         = $(LIB_SUFFIX)"
+	@echo "DLL_SUFFIX         = $(DLL_SUFFIX)"
+	@echo "IMPORT_LIB_SUFFIX  = $(IMPORT_LIB_SUFFIX)"
+	@echo "INSTALL            = $(INSTALL)"
+	@echo "VPATH              = $(VPATH)"
+
+showhost:
+	@echo "HOST_CC            = $(HOST_CC)"
+	@echo "HOST_CXX           = $(HOST_CXX)"
+	@echo "HOST_CFLAGS        = $(HOST_CFLAGS)"
+	@echo "HOST_LDFLAGS       = $(HOST_LDFLAGS)"
+	@echo "HOST_LIBS          = $(HOST_LIBS)"
+	@echo "HOST_EXTRA_LIBS    = $(HOST_EXTRA_LIBS)"
+	@echo "HOST_EXTRA_DEPS    = $(HOST_EXTRA_DEPS)"
+	@echo "HOST_PROGRAM       = $(HOST_PROGRAM)"
+	@echo "HOST_OBJS          = $(HOST_OBJS)"
+	@echo "HOST_PROGOBJS      = $(HOST_PROGOBJS)"
+	@echo "HOST_LIBRARY       = $(HOST_LIBRARY)"
+
+showbuildmods::
+	@echo "Module dirs	= $(BUILD_MODULE_DIRS)"
+
+INCLUDED_DEBUGMAKE_MK = 1
+endif #}
--- a/config/makefiles/makeutils.mk
+++ b/config/makefiles/makeutils.mk
@@ -62,18 +62,21 @@ is_XinY =$(filter $(1),$(call subargv,3,
 # Provide an alternate var to support testing
 ifdef MAKEUTILS_UNIT_TEST
   mcg_goals=TEST_MAKECMDGOALS
 else
   mcg_goals=MAKECMDGOALS
 endif
 
 # Intent: Conditionals for detecting common/tier target use
-#   Todo: are check, install, test needed ?
-isTargetStem       = $(sort $(foreach pat, $(1)% %$(1), $(call is_XinY,$(pat),${$(mcg_goals)})))
+isTargetStem       = $(sort \
+  $(foreach var,$(getargv),\
+    $(foreach pat,$(var)% %$(var),\
+      $(call is_XinY,$(pat),${$(mcg_goals)})\
+  )))
 isTargetStemClean  = $(call isTargetStem,clean)
 isTargetStemExport = $(call isTargetStem,export)
 isTargetStemLibs   = $(call isTargetStem,libs)
 isTargetStemTools  = $(call isTargetStem,tools)
 
 ##################################################
 # Intent: Validation functions / unit test helpers
 
--- a/config/makefiles/test/check_XinY.mk
+++ b/config/makefiles/test/check_XinY.mk
@@ -38,8 +38,33 @@ wanted  := clean distclean clean-level-1
 #     match: clean, distclean, clean-level-1
 #   exclude: FcleanG
 TEST_MAKECMDGOALS := $(val)
 $(call errorifneq,3,$(words $(call isTargetStemClean)))
 
 TEST_MAKECMDGOALS := invalid
 $(call errorifneq,$(zero),$(words $(call isTargetStemClean)))
 
+
+#############################
+ifdef VERBOSE
+  $(call banner,Unit test: isTargetStem)
+endif
+
+# Verify list argument processing
+TEST_MAKECMDGOALS := echo
+$(call errorifneq,$(one),$(words $(call isTargetStem,echo,show)))
+
+TEST_MAKECMDGOALS := echo-123
+$(call errorifneq,$(one),$(words $(call isTargetStem,echo,show)))
+
+TEST_MAKECMDGOALS := show
+$(call errorifneq,$(one),$(words $(call isTargetStem,echo,show)))
+
+TEST_MAKECMDGOALS := show-123
+$(call errorifneq,$(one),$(words $(call isTargetStem,echo,show)))
+
+TEST_MAKECMDGOALS := show-123-echo
+$(call errorifneq,$(one),$(words $(call isTargetStem,echo,show)))
+
+TEST_MAKECMDGOALS := invalid
+$(call errorifneq,$(zero),$(words $(call isTargetStem,echo,show)))
+
new file mode 100644
--- /dev/null
+++ b/config/makefiles/xpcshell.mk
@@ -0,0 +1,128 @@
+# -*- 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/.
+#
+
+ifndef INCLUDED_TESTS_XPCSHELL_MK #{
+
+ifdef XPCSHELL_TESTS #{
+
+ifndef relativesrcdir
+$(error Must define relativesrcdir when defining XPCSHELL_TESTS.)
+endif
+
+define _INSTALL_TESTS
+$(DIR_INSTALL) $(wildcard $(srcdir)/$(dir)/*) $(testxpcobjdir)/$(relativesrcdir)/$(dir)
+
+endef # do not remove the blank line!
+
+SOLO_FILE ?= $(error Specify a test filename in SOLO_FILE when using check-interactive or check-one)
+
+testxpcsrcdir = $(topsrcdir)/testing/xpcshell
+
+libs:: libs-xpcshell-tests
+
+###########################################################################
+libs-xpcshell-tests:
+	$(foreach dir,$(XPCSHELL_TESTS),$(_INSTALL_TESTS))
+ifndef NO_XPCSHELL_MANIFEST_CHECK #{
+	$(PYTHON) $(MOZILLA_DIR)/build/xpccheck.py \
+	  $(topsrcdir) \
+	  $(topsrcdir)/testing/xpcshell/xpcshell.ini \
+	  $(addprefix $(MOZILLA_DIR)/$(relativesrcdir)/,$(XPCSHELL_TESTS))
+endif #} NO_XPCSHELL_MANIFEST_CHECK 
+
+###########################################################################
+# Execute all tests in the $(XPCSHELL_TESTS) directories.
+# See also testsuite-targets.mk 'xpcshell-tests' target for global execution.
+xpcshell-tests:
+	$(PYTHON) -u $(topsrcdir)/config/pythonpath.py \
+	  -I$(topsrcdir)/build \
+      -I$(DEPTH)/_tests/mozbase/mozinfo \
+	  $(testxpcsrcdir)/runxpcshelltests.py \
+	  --symbols-path=$(DIST)/crashreporter-symbols \
+	  --build-info-json=$(DEPTH)/mozinfo.json \
+	  --tests-root-dir=$(testxpcobjdir) \
+	  --testing-modules-dir=$(DEPTH)/_tests/modules \
+	  --xunit-file=$(testxpcobjdir)/$(relativesrcdir)/results.xml \
+	  --xunit-suite-name=xpcshell \
+	  $(EXTRA_TEST_ARGS) \
+	  $(LIBXUL_DIST)/bin/xpcshell \
+	  $(foreach dir,$(XPCSHELL_TESTS),$(testxpcobjdir)/$(relativesrcdir)/$(dir))
+
+xpcshell-tests-remote: DM_TRANS?=adb
+xpcshell-tests-remote:
+	$(PYTHON) -u $(topsrcdir)/config/pythonpath.py \
+	  -I$(topsrcdir)/build \
+	  -I$(topsrcdir)/build/mobile \
+	  $(topsrcdir)/testing/xpcshell/remotexpcshelltests.py \
+	  --symbols-path=$(DIST)/crashreporter-symbols \
+	  --build-info-json=$(DEPTH)/mozinfo.json \
+	  $(EXTRA_TEST_ARGS) \
+	  --dm_trans=$(DM_TRANS) \
+	  --deviceIP=${TEST_DEVICE} \
+	  --objdir=$(DEPTH) \
+	  $(foreach dir,$(XPCSHELL_TESTS),$(testxpcobjdir)/$(relativesrcdir)/$(dir))
+
+###########################################################################
+# Execute a single test, specified in $(SOLO_FILE), but don't automatically
+# start the test. Instead, present the xpcshell prompt so the user can
+# attach a debugger and then start the test.
+check-interactive:
+	$(PYTHON) -u $(topsrcdir)/config/pythonpath.py \
+	  -I$(topsrcdir)/build \
+      -I$(DEPTH)/_tests/mozbase/mozinfo \
+	  $(testxpcsrcdir)/runxpcshelltests.py \
+	  --symbols-path=$(DIST)/crashreporter-symbols \
+	  --build-info-json=$(DEPTH)/mozinfo.json \
+	  --test-path=$(SOLO_FILE) \
+	  --testing-modules-dir=$(DEPTH)/_tests/modules \
+	  --profile-name=$(MOZ_APP_NAME) \
+	  --interactive \
+	  $(LIBXUL_DIST)/bin/xpcshell \
+	  $(foreach dir,$(XPCSHELL_TESTS),$(testxpcobjdir)/$(relativesrcdir)/$(dir))
+
+# Execute a single test, specified in $(SOLO_FILE)
+check-one:
+	$(PYTHON) -u $(topsrcdir)/config/pythonpath.py \
+	  -I$(topsrcdir)/build \
+      -I$(DEPTH)/_tests/mozbase/mozinfo \
+	  $(testxpcsrcdir)/runxpcshelltests.py \
+	  --symbols-path=$(DIST)/crashreporter-symbols \
+	  --build-info-json=$(DEPTH)/mozinfo.json \
+	  --test-path=$(SOLO_FILE) \
+	  --testing-modules-dir=$(DEPTH)/_tests/modules \
+	  --profile-name=$(MOZ_APP_NAME) \
+	  --verbose \
+	  $(EXTRA_TEST_ARGS) \
+	  $(LIBXUL_DIST)/bin/xpcshell \
+	  $(foreach dir,$(XPCSHELL_TESTS),$(testxpcobjdir)/$(relativesrcdir)/$(dir))
+
+check-one-remote: DM_TRANS?=adb
+check-one-remote:
+	$(PYTHON) -u $(topsrcdir)/config/pythonpath.py \
+	  -I$(topsrcdir)/build \
+	  -I$(topsrcdir)/build/mobile \
+	  $(testxpcsrcdir)/remotexpcshelltests.py \
+	  --symbols-path=$(DIST)/crashreporter-symbols \
+	  --build-info-json=$(DEPTH)/mozinfo.json \
+	  --test-path=$(SOLO_FILE) \
+	  --profile-name=$(MOZ_APP_NAME) \
+	  --verbose \
+	  $(EXTRA_TEST_ARGS) \
+	  --dm_trans=$(DM_TRANS) \
+	  --deviceIP=${TEST_DEVICE} \
+	  --objdir=$(DEPTH) \
+          --noSetup \
+	  $(foreach dir,$(XPCSHELL_TESTS),$(testxpcobjdir)/$(relativesrcdir)/$(dir))
+
+
+.PHONY: xpcshell-tests check-interactive check-one libs-xpcshell-tests
+
+endif #} XPCSHELL_TESTS
+
+INCLUDED_TESTS_XPCSHELL_MK = 1
+endif #} INCLUDED_TESTS_XPCSHELL_MK
--- a/config/rules.mk
+++ b/config/rules.mk
@@ -80,118 +80,19 @@ ifdef ENABLE_TESTS
 # The current developer workflow expects tests to be updated when processing
 # the default target. If we ever change this implementation, the behavior
 # should be preserved or the change should be widely communicated. A
 # consequence of not processing test dir targets during the default target is
 # that changes to tests may not be updated and code could assume to pass
 # locally against non-current test code.
 DIRS += $(TEST_DIRS)
 
-ifdef XPCSHELL_TESTS
-ifndef relativesrcdir
-$(error Must define relativesrcdir when defining XPCSHELL_TESTS.)
-endif
-
-define _INSTALL_TESTS
-$(DIR_INSTALL) $(wildcard $(srcdir)/$(dir)/*) $(testxpcobjdir)/$(relativesrcdir)/$(dir)
-
-endef # do not remove the blank line!
-
-SOLO_FILE ?= $(error Specify a test filename in SOLO_FILE when using check-interactive or check-one)
-
-libs::
-	$(foreach dir,$(XPCSHELL_TESTS),$(_INSTALL_TESTS))
-ifndef NO_XPCSHELL_MANIFEST_CHECK
-	$(PYTHON) $(MOZILLA_DIR)/build/xpccheck.py \
-	  $(topsrcdir) \
-	  $(topsrcdir)/testing/xpcshell/xpcshell.ini \
-	  $(addprefix $(MOZILLA_DIR)/$(relativesrcdir)/,$(XPCSHELL_TESTS))
-endif
-
-testxpcsrcdir = $(topsrcdir)/testing/xpcshell
-
-# Execute all tests in the $(XPCSHELL_TESTS) directories.
-# See also testsuite-targets.mk 'xpcshell-tests' target for global execution.
-xpcshell-tests:
-	$(PYTHON) -u $(topsrcdir)/config/pythonpath.py \
-	  -I$(topsrcdir)/build -I$(DEPTH)/_tests/mozbase/mozinfo \
-	  $(testxpcsrcdir)/runxpcshelltests.py \
-	  --symbols-path=$(DIST)/crashreporter-symbols \
-	  --build-info-json=$(DEPTH)/mozinfo.json \
-	  --tests-root-dir=$(testxpcobjdir) \
-	  --testing-modules-dir=$(DEPTH)/_tests/modules \
-	  --xunit-file=$(testxpcobjdir)/$(relativesrcdir)/results.xml \
-	  --xunit-suite-name=xpcshell \
-	  $(EXTRA_TEST_ARGS) \
-	  $(LIBXUL_DIST)/bin/xpcshell \
-	  $(foreach dir,$(XPCSHELL_TESTS),$(testxpcobjdir)/$(relativesrcdir)/$(dir))
-
-xpcshell-tests-remote: DM_TRANS?=adb
-xpcshell-tests-remote:
-	$(PYTHON) -u $(topsrcdir)/config/pythonpath.py \
-	  -I$(topsrcdir)/build \
-	  -I$(topsrcdir)/build/mobile \
-	  $(topsrcdir)/testing/xpcshell/remotexpcshelltests.py \
-	  --symbols-path=$(DIST)/crashreporter-symbols \
-	  --build-info-json=$(DEPTH)/mozinfo.json \
-	  $(EXTRA_TEST_ARGS) \
-	  --dm_trans=$(DM_TRANS) \
-	  --deviceIP=${TEST_DEVICE} \
-	  --objdir=$(DEPTH) \
-	  $(foreach dir,$(XPCSHELL_TESTS),$(testxpcobjdir)/$(relativesrcdir)/$(dir))
-
-# Execute a single test, specified in $(SOLO_FILE), but don't automatically
-# start the test. Instead, present the xpcshell prompt so the user can
-# attach a debugger and then start the test.
-check-interactive:
-	$(PYTHON) -u $(topsrcdir)/config/pythonpath.py \
-	  -I$(topsrcdir)/build -I$(DEPTH)/_tests/mozbase/mozinfo \
-	  $(testxpcsrcdir)/runxpcshelltests.py \
-	  --symbols-path=$(DIST)/crashreporter-symbols \
-	  --build-info-json=$(DEPTH)/mozinfo.json \
-	  --test-path=$(SOLO_FILE) \
-	  --testing-modules-dir=$(DEPTH)/_tests/modules \
-	  --profile-name=$(MOZ_APP_NAME) \
-	  --interactive \
-	  $(LIBXUL_DIST)/bin/xpcshell \
-	  $(foreach dir,$(XPCSHELL_TESTS),$(testxpcobjdir)/$(relativesrcdir)/$(dir))
-
-# Execute a single test, specified in $(SOLO_FILE)
-check-one:
-	$(PYTHON) -u $(topsrcdir)/config/pythonpath.py \
-	  -I$(topsrcdir)/build -I$(DEPTH)/_tests/mozbase/mozinfo \
-	  $(testxpcsrcdir)/runxpcshelltests.py \
-	  --symbols-path=$(DIST)/crashreporter-symbols \
-	  --build-info-json=$(DEPTH)/mozinfo.json \
-	  --test-path=$(SOLO_FILE) \
-	  --testing-modules-dir=$(DEPTH)/_tests/modules \
-	  --profile-name=$(MOZ_APP_NAME) \
-	  --verbose \
-	  $(EXTRA_TEST_ARGS) \
-	  $(LIBXUL_DIST)/bin/xpcshell \
-	  $(foreach dir,$(XPCSHELL_TESTS),$(testxpcobjdir)/$(relativesrcdir)/$(dir))
-
-check-one-remote: DM_TRANS?=adb
-check-one-remote:
-	$(PYTHON) -u $(topsrcdir)/config/pythonpath.py \
-	  -I$(topsrcdir)/build \
-	  -I$(topsrcdir)/build/mobile \
-	  $(testxpcsrcdir)/remotexpcshelltests.py \
-	  --symbols-path=$(DIST)/crashreporter-symbols \
-	  --build-info-json=$(DEPTH)/mozinfo.json \
-	  --test-path=$(SOLO_FILE) \
-	  --profile-name=$(MOZ_APP_NAME) \
-	  --verbose \
-	  $(EXTRA_TEST_ARGS) \
-	  --dm_trans=$(DM_TRANS) \
-	  --deviceIP=${TEST_DEVICE} \
-	  --objdir=$(DEPTH) \
-          --noSetup \
-	  $(foreach dir,$(XPCSHELL_TESTS),$(testxpcobjdir)/$(relativesrcdir)/$(dir))
-endif # XPCSHELL_TESTS
+ifndef INCLUDED_TESTS_XPCSHELL_MK #{
+  include $(topsrcdir)/config/makefiles/xpcshell.mk
+endif #}
 
 ifdef CPP_UNIT_TESTS
 
 # Compile the tests to $(DIST)/bin.  Make lots of niceties available by default
 # through TestHarness.h, by modifying the list of includes and the libs against
 # which stuff links.
 CPPSRCS += $(CPP_UNIT_TESTS)
 SIMPLE_PROGRAMS += $(CPP_UNIT_TESTS:.cpp=$(BIN_SUFFIX))
@@ -202,17 +103,17 @@ LIBS += $(XPCOM_GLUE_LDOPTS) $(NSPR_LIBS
 check::
 	@$(EXIT_ON_ERROR) \
 	  for f in $(subst .cpp,$(BIN_SUFFIX),$(CPP_UNIT_TESTS)); do \
 	    XPCOM_DEBUG_BREAK=stack-and-abort $(RUN_TEST_PROGRAM) $(DIST)/bin/$$f; \
 	  done
 
 endif # CPP_UNIT_TESTS
 
-.PHONY: check xpcshell-tests check-interactive check-one
+.PHONY: check
 
 endif # ENABLE_TESTS
 
 
 #
 # Library rules
 #
 # If FORCE_STATIC_LIB is set, build a static library.
@@ -1370,16 +1271,17 @@ ifneq ($(AUTOCFG_JS_EXPORTS),)
 	$(NSINSTALL) -D $@
 
 ifndef NO_DIST_INSTALL
 export:: $(AUTOCFG_JS_EXPORTS) $(FINAL_TARGET)/defaults/autoconfig
 	$(INSTALL) $(IFLAGS1) $^
 endif
 
 endif
+
 ################################################################################
 # Export the elements of $(XPIDLSRCS)
 # generating .h and .xpt files and moving them to the appropriate places.
 
 ifneq ($(XPIDLSRCS),)
 
 export:: $(patsubst %.idl,$(XPIDL_GEN_DIR)/%.h, $(XPIDLSRCS))
 
@@ -1843,116 +1745,22 @@ FORCE:
 
 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)
-
-echo-tier-dirs:
-	@$(foreach tier,$(TIERS),echo '$(tier):'; echo '  dirs: $(tier_$(tier)_dirs)'; echo '  staticdirs: $(tier_$(tier)_staticdirs)'; )
-
-echo-dirs:
-	@echo $(DIRS)
-
-echo-module:
-	@echo $(MODULE)
-
-echo-depth-path:
-	@$(topsrcdir)/build/unix/print-depth-path.sh
-
-echo-module-name:
-	@$(topsrcdir)/build/package/rpm/print-module-name.sh
-
-echo-module-filelist:
-	@$(topsrcdir)/build/package/rpm/print-module-filelist.sh
-
-showtargs:
-ifneq (,$(filter $(PROGRAM) $(HOST_PROGRAM) $(SIMPLE_PROGRAMS) $(HOST_LIBRARY) $(LIBRARY) $(SHARED_LIBRARY),$(TARGETS)))
-	@echo --------------------------------------------------------------------------------
-	@echo "PROGRAM             = $(PROGRAM)"
-	@echo "SIMPLE_PROGRAMS     = $(SIMPLE_PROGRAMS)"
-	@echo "LIBRARY             = $(LIBRARY)"
-	@echo "SHARED_LIBRARY      = $(SHARED_LIBRARY)"
-	@echo "SHARED_LIBRARY_LIBS = $(SHARED_LIBRARY_LIBS)"
-	@echo "LIBS                = $(LIBS)"
-	@echo "DEF_FILE            = $(DEF_FILE)"
-	@echo "IMPORT_LIBRARY      = $(IMPORT_LIBRARY)"
-	@echo "STATIC_LIBS         = $(STATIC_LIBS)"
-	@echo "SHARED_LIBS         = $(SHARED_LIBS)"
-	@echo "EXTRA_DSO_LIBS      = $(EXTRA_DSO_LIBS)"
-	@echo "EXTRA_DSO_LDOPTS    = $(EXTRA_DSO_LDOPTS)"
-	@echo "DEPENDENT_LIBS      = $(DEPENDENT_LIBS)"
-	@echo --------------------------------------------------------------------------------
-endif
-	$(LOOP_OVER_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)"
-	@echo "CPP                = $(CPP)"
-	@echo "LD                 = $(LD)"
-	@echo "AR                 = $(AR)"
-	@echo "IMPLIB             = $(IMPLIB)"
-	@echo "FILTER             = $(FILTER)"
-	@echo "MKSHLIB            = $(MKSHLIB)"
-	@echo "MKCSHLIB           = $(MKCSHLIB)"
-	@echo "RC                 = $(RC)"
-	@echo "MC                 = $(MC)"
-	@echo "CFLAGS             = $(CFLAGS)"
-	@echo "OS_CFLAGS          = $(OS_CFLAGS)"
-	@echo "COMPILE_CFLAGS     = $(COMPILE_CFLAGS)"
-	@echo "CXXFLAGS           = $(CXXFLAGS)"
-	@echo "OS_CXXFLAGS        = $(OS_CXXFLAGS)"
-	@echo "COMPILE_CXXFLAGS   = $(COMPILE_CXXFLAGS)"
-	@echo "COMPILE_CMFLAGS    = $(COMPILE_CMFLAGS)"
-	@echo "COMPILE_CMMFLAGS   = $(COMPILE_CMMFLAGS)"
-	@echo "LDFLAGS            = $(LDFLAGS)"
-	@echo "OS_LDFLAGS         = $(OS_LDFLAGS)"
-	@echo "DSO_LDOPTS         = $(DSO_LDOPTS)"
-	@echo "OS_INCLUDES        = $(OS_INCLUDES)"
-	@echo "OS_LIBS            = $(OS_LIBS)"
-	@echo "EXTRA_LIBS         = $(EXTRA_LIBS)"
-	@echo "BIN_FLAGS          = $(BIN_FLAGS)"
-	@echo "INCLUDES           = $(INCLUDES)"
-	@echo "DEFINES            = $(DEFINES)"
-	@echo "ACDEFINES          = $(ACDEFINES)"
-	@echo "BIN_SUFFIX         = $(BIN_SUFFIX)"
-	@echo "LIB_SUFFIX         = $(LIB_SUFFIX)"
-	@echo "DLL_SUFFIX         = $(DLL_SUFFIX)"
-	@echo "IMPORT_LIB_SUFFIX  = $(IMPORT_LIB_SUFFIX)"
-	@echo "INSTALL            = $(INSTALL)"
-	@echo "VPATH              = $(VPATH)"
-
-showhost:
-	@echo "HOST_CC            = $(HOST_CC)"
-	@echo "HOST_CXX           = $(HOST_CXX)"
-	@echo "HOST_CFLAGS        = $(HOST_CFLAGS)"
-	@echo "HOST_LDFLAGS       = $(HOST_LDFLAGS)"
-	@echo "HOST_LIBS          = $(HOST_LIBS)"
-	@echo "HOST_EXTRA_LIBS    = $(HOST_EXTRA_LIBS)"
-	@echo "HOST_EXTRA_DEPS    = $(HOST_EXTRA_DEPS)"
-	@echo "HOST_PROGRAM       = $(HOST_PROGRAM)"
-	@echo "HOST_OBJS          = $(HOST_OBJS)"
-	@echo "HOST_PROGOBJS      = $(HOST_PROGOBJS)"
-	@echo "HOST_LIBRARY       = $(HOST_LIBRARY)"
-
-showbuildmods::
-	@echo "Module dirs	= $(BUILD_MODULE_DIRS)"
+ifndef INCLUDED_DEBUGMAKE_MK #{
+  ## Only parse when an echo* or show* target is requested
+  ifneq (,$(call isTargetStem,echo,show))
+    include $(topsrcdir)/config/makefiles/debugmake.mk
+  endif #}
+endif #}
 
 documentation:
 	@cd $(DEPTH)
 	$(DOXYGEN) $(DEPTH)/config/doxygen.cfg
 
 ifdef ENABLE_TESTS
 check:: $(SUBMAKEFILES) $(MAKE_DIRS)
 	$(LOOP_OVER_PARALLEL_DIRS)
new file mode 100644
--- /dev/null
+++ b/js/src/config/makefiles/debugmake.mk
@@ -0,0 +1,118 @@
+# -*- 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/.
+#
+
+###########################################################################
+## Intent: Helper targets for displaying variables and state information
+###########################################################################
+
+# Support usage outside of config/rules.mk
+ifndef INCLUDED_DEBUGMAKE_MK #{
+
+echo-variable-%:
+	@echo "$($*)"
+
+echo-tiers:
+	@echo $(TIERS)
+
+echo-tier-dirs:
+	@$(foreach tier,$(TIERS),echo '$(tier):'; echo '  dirs: $(tier_$(tier)_dirs)'; echo '  staticdirs: $(tier_$(tier)_staticdirs)'; )
+
+echo-dirs:
+	@echo $(DIRS)
+
+echo-module:
+	@echo $(MODULE)
+
+echo-depth-path:
+	@$(topsrcdir)/build/unix/print-depth-path.sh
+
+echo-module-name:
+	@$(topsrcdir)/build/package/rpm/print-module-name.sh
+
+echo-module-filelist:
+	@$(topsrcdir)/build/package/rpm/print-module-filelist.sh
+
+showtargs:
+ifneq (,$(filter $(PROGRAM) $(HOST_PROGRAM) $(SIMPLE_PROGRAMS) $(HOST_LIBRARY) $(LIBRARY) $(SHARED_LIBRARY),$(TARGETS)))
+	@echo --------------------------------------------------------------------------------
+	@echo "PROGRAM             = $(PROGRAM)"
+	@echo "SIMPLE_PROGRAMS     = $(SIMPLE_PROGRAMS)"
+	@echo "LIBRARY             = $(LIBRARY)"
+	@echo "SHARED_LIBRARY      = $(SHARED_LIBRARY)"
+	@echo "SHARED_LIBRARY_LIBS = $(SHARED_LIBRARY_LIBS)"
+	@echo "LIBS                = $(LIBS)"
+	@echo "DEF_FILE            = $(DEF_FILE)"
+	@echo "IMPORT_LIBRARY      = $(IMPORT_LIBRARY)"
+	@echo "STATIC_LIBS         = $(STATIC_LIBS)"
+	@echo "SHARED_LIBS         = $(SHARED_LIBS)"
+	@echo "EXTRA_DSO_LIBS      = $(EXTRA_DSO_LIBS)"
+	@echo "EXTRA_DSO_LDOPTS    = $(EXTRA_DSO_LDOPTS)"
+	@echo "DEPENDENT_LIBS      = $(DEPENDENT_LIBS)"
+	@echo --------------------------------------------------------------------------------
+endif
+	$(LOOP_OVER_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)"
+	@echo "CPP                = $(CPP)"
+	@echo "LD                 = $(LD)"
+	@echo "AR                 = $(AR)"
+	@echo "IMPLIB             = $(IMPLIB)"
+	@echo "FILTER             = $(FILTER)"
+	@echo "MKSHLIB            = $(MKSHLIB)"
+	@echo "MKCSHLIB           = $(MKCSHLIB)"
+	@echo "RC                 = $(RC)"
+	@echo "MC                 = $(MC)"
+	@echo "CFLAGS             = $(CFLAGS)"
+	@echo "OS_CFLAGS          = $(OS_CFLAGS)"
+	@echo "COMPILE_CFLAGS     = $(COMPILE_CFLAGS)"
+	@echo "CXXFLAGS           = $(CXXFLAGS)"
+	@echo "OS_CXXFLAGS        = $(OS_CXXFLAGS)"
+	@echo "COMPILE_CXXFLAGS   = $(COMPILE_CXXFLAGS)"
+	@echo "COMPILE_CMFLAGS    = $(COMPILE_CMFLAGS)"
+	@echo "COMPILE_CMMFLAGS   = $(COMPILE_CMMFLAGS)"
+	@echo "LDFLAGS            = $(LDFLAGS)"
+	@echo "OS_LDFLAGS         = $(OS_LDFLAGS)"
+	@echo "DSO_LDOPTS         = $(DSO_LDOPTS)"
+	@echo "OS_INCLUDES        = $(OS_INCLUDES)"
+	@echo "OS_LIBS            = $(OS_LIBS)"
+	@echo "EXTRA_LIBS         = $(EXTRA_LIBS)"
+	@echo "BIN_FLAGS          = $(BIN_FLAGS)"
+	@echo "INCLUDES           = $(INCLUDES)"
+	@echo "DEFINES            = $(DEFINES)"
+	@echo "ACDEFINES          = $(ACDEFINES)"
+	@echo "BIN_SUFFIX         = $(BIN_SUFFIX)"
+	@echo "LIB_SUFFIX         = $(LIB_SUFFIX)"
+	@echo "DLL_SUFFIX         = $(DLL_SUFFIX)"
+	@echo "IMPORT_LIB_SUFFIX  = $(IMPORT_LIB_SUFFIX)"
+	@echo "INSTALL            = $(INSTALL)"
+	@echo "VPATH              = $(VPATH)"
+
+showhost:
+	@echo "HOST_CC            = $(HOST_CC)"
+	@echo "HOST_CXX           = $(HOST_CXX)"
+	@echo "HOST_CFLAGS        = $(HOST_CFLAGS)"
+	@echo "HOST_LDFLAGS       = $(HOST_LDFLAGS)"
+	@echo "HOST_LIBS          = $(HOST_LIBS)"
+	@echo "HOST_EXTRA_LIBS    = $(HOST_EXTRA_LIBS)"
+	@echo "HOST_EXTRA_DEPS    = $(HOST_EXTRA_DEPS)"
+	@echo "HOST_PROGRAM       = $(HOST_PROGRAM)"
+	@echo "HOST_OBJS          = $(HOST_OBJS)"
+	@echo "HOST_PROGOBJS      = $(HOST_PROGOBJS)"
+	@echo "HOST_LIBRARY       = $(HOST_LIBRARY)"
+
+showbuildmods::
+	@echo "Module dirs	= $(BUILD_MODULE_DIRS)"
+
+INCLUDED_DEBUGMAKE_MK = 1
+endif #}
--- a/js/src/config/makefiles/makeutils.mk
+++ b/js/src/config/makefiles/makeutils.mk
@@ -62,18 +62,21 @@ is_XinY =$(filter $(1),$(call subargv,3,
 # Provide an alternate var to support testing
 ifdef MAKEUTILS_UNIT_TEST
   mcg_goals=TEST_MAKECMDGOALS
 else
   mcg_goals=MAKECMDGOALS
 endif
 
 # Intent: Conditionals for detecting common/tier target use
-#   Todo: are check, install, test needed ?
-isTargetStem       = $(sort $(foreach pat, $(1)% %$(1), $(call is_XinY,$(pat),${$(mcg_goals)})))
+isTargetStem       = $(sort \
+  $(foreach var,$(getargv),\
+    $(foreach pat,$(var)% %$(var),\
+      $(call is_XinY,$(pat),${$(mcg_goals)})\
+  )))
 isTargetStemClean  = $(call isTargetStem,clean)
 isTargetStemExport = $(call isTargetStem,export)
 isTargetStemLibs   = $(call isTargetStem,libs)
 isTargetStemTools  = $(call isTargetStem,tools)
 
 ##################################################
 # Intent: Validation functions / unit test helpers
 
new file mode 100644
--- /dev/null
+++ b/js/src/config/makefiles/xpcshell.mk
@@ -0,0 +1,128 @@
+# -*- 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/.
+#
+
+ifndef INCLUDED_TESTS_XPCSHELL_MK #{
+
+ifdef XPCSHELL_TESTS #{
+
+ifndef relativesrcdir
+$(error Must define relativesrcdir when defining XPCSHELL_TESTS.)
+endif
+
+define _INSTALL_TESTS
+$(DIR_INSTALL) $(wildcard $(srcdir)/$(dir)/*) $(testxpcobjdir)/$(relativesrcdir)/$(dir)
+
+endef # do not remove the blank line!
+
+SOLO_FILE ?= $(error Specify a test filename in SOLO_FILE when using check-interactive or check-one)
+
+testxpcsrcdir = $(topsrcdir)/testing/xpcshell
+
+libs:: libs-xpcshell-tests
+
+###########################################################################
+libs-xpcshell-tests:
+	$(foreach dir,$(XPCSHELL_TESTS),$(_INSTALL_TESTS))
+ifndef NO_XPCSHELL_MANIFEST_CHECK #{
+	$(PYTHON) $(MOZILLA_DIR)/build/xpccheck.py \
+	  $(topsrcdir) \
+	  $(topsrcdir)/testing/xpcshell/xpcshell.ini \
+	  $(addprefix $(MOZILLA_DIR)/$(relativesrcdir)/,$(XPCSHELL_TESTS))
+endif #} NO_XPCSHELL_MANIFEST_CHECK 
+
+###########################################################################
+# Execute all tests in the $(XPCSHELL_TESTS) directories.
+# See also testsuite-targets.mk 'xpcshell-tests' target for global execution.
+xpcshell-tests:
+	$(PYTHON) -u $(topsrcdir)/config/pythonpath.py \
+	  -I$(topsrcdir)/build \
+      -I$(DEPTH)/_tests/mozbase/mozinfo \
+	  $(testxpcsrcdir)/runxpcshelltests.py \
+	  --symbols-path=$(DIST)/crashreporter-symbols \
+	  --build-info-json=$(DEPTH)/mozinfo.json \
+	  --tests-root-dir=$(testxpcobjdir) \
+	  --testing-modules-dir=$(DEPTH)/_tests/modules \
+	  --xunit-file=$(testxpcobjdir)/$(relativesrcdir)/results.xml \
+	  --xunit-suite-name=xpcshell \
+	  $(EXTRA_TEST_ARGS) \
+	  $(LIBXUL_DIST)/bin/xpcshell \
+	  $(foreach dir,$(XPCSHELL_TESTS),$(testxpcobjdir)/$(relativesrcdir)/$(dir))
+
+xpcshell-tests-remote: DM_TRANS?=adb
+xpcshell-tests-remote:
+	$(PYTHON) -u $(topsrcdir)/config/pythonpath.py \
+	  -I$(topsrcdir)/build \
+	  -I$(topsrcdir)/build/mobile \
+	  $(topsrcdir)/testing/xpcshell/remotexpcshelltests.py \
+	  --symbols-path=$(DIST)/crashreporter-symbols \
+	  --build-info-json=$(DEPTH)/mozinfo.json \
+	  $(EXTRA_TEST_ARGS) \
+	  --dm_trans=$(DM_TRANS) \
+	  --deviceIP=${TEST_DEVICE} \
+	  --objdir=$(DEPTH) \
+	  $(foreach dir,$(XPCSHELL_TESTS),$(testxpcobjdir)/$(relativesrcdir)/$(dir))
+
+###########################################################################
+# Execute a single test, specified in $(SOLO_FILE), but don't automatically
+# start the test. Instead, present the xpcshell prompt so the user can
+# attach a debugger and then start the test.
+check-interactive:
+	$(PYTHON) -u $(topsrcdir)/config/pythonpath.py \
+	  -I$(topsrcdir)/build \
+      -I$(DEPTH)/_tests/mozbase/mozinfo \
+	  $(testxpcsrcdir)/runxpcshelltests.py \
+	  --symbols-path=$(DIST)/crashreporter-symbols \
+	  --build-info-json=$(DEPTH)/mozinfo.json \
+	  --test-path=$(SOLO_FILE) \
+	  --testing-modules-dir=$(DEPTH)/_tests/modules \
+	  --profile-name=$(MOZ_APP_NAME) \
+	  --interactive \
+	  $(LIBXUL_DIST)/bin/xpcshell \
+	  $(foreach dir,$(XPCSHELL_TESTS),$(testxpcobjdir)/$(relativesrcdir)/$(dir))
+
+# Execute a single test, specified in $(SOLO_FILE)
+check-one:
+	$(PYTHON) -u $(topsrcdir)/config/pythonpath.py \
+	  -I$(topsrcdir)/build \
+      -I$(DEPTH)/_tests/mozbase/mozinfo \
+	  $(testxpcsrcdir)/runxpcshelltests.py \
+	  --symbols-path=$(DIST)/crashreporter-symbols \
+	  --build-info-json=$(DEPTH)/mozinfo.json \
+	  --test-path=$(SOLO_FILE) \
+	  --testing-modules-dir=$(DEPTH)/_tests/modules \
+	  --profile-name=$(MOZ_APP_NAME) \
+	  --verbose \
+	  $(EXTRA_TEST_ARGS) \
+	  $(LIBXUL_DIST)/bin/xpcshell \
+	  $(foreach dir,$(XPCSHELL_TESTS),$(testxpcobjdir)/$(relativesrcdir)/$(dir))
+
+check-one-remote: DM_TRANS?=adb
+check-one-remote:
+	$(PYTHON) -u $(topsrcdir)/config/pythonpath.py \
+	  -I$(topsrcdir)/build \
+	  -I$(topsrcdir)/build/mobile \
+	  $(testxpcsrcdir)/remotexpcshelltests.py \
+	  --symbols-path=$(DIST)/crashreporter-symbols \
+	  --build-info-json=$(DEPTH)/mozinfo.json \
+	  --test-path=$(SOLO_FILE) \
+	  --profile-name=$(MOZ_APP_NAME) \
+	  --verbose \
+	  $(EXTRA_TEST_ARGS) \
+	  --dm_trans=$(DM_TRANS) \
+	  --deviceIP=${TEST_DEVICE} \
+	  --objdir=$(DEPTH) \
+          --noSetup \
+	  $(foreach dir,$(XPCSHELL_TESTS),$(testxpcobjdir)/$(relativesrcdir)/$(dir))
+
+
+.PHONY: xpcshell-tests check-interactive check-one libs-xpcshell-tests
+
+endif #} XPCSHELL_TESTS
+
+INCLUDED_TESTS_XPCSHELL_MK = 1
+endif #} INCLUDED_TESTS_XPCSHELL_MK
--- a/js/src/config/rules.mk
+++ b/js/src/config/rules.mk
@@ -80,118 +80,19 @@ ifdef ENABLE_TESTS
 # The current developer workflow expects tests to be updated when processing
 # the default target. If we ever change this implementation, the behavior
 # should be preserved or the change should be widely communicated. A
 # consequence of not processing test dir targets during the default target is
 # that changes to tests may not be updated and code could assume to pass
 # locally against non-current test code.
 DIRS += $(TEST_DIRS)
 
-ifdef XPCSHELL_TESTS
-ifndef relativesrcdir
-$(error Must define relativesrcdir when defining XPCSHELL_TESTS.)
-endif
-
-define _INSTALL_TESTS
-$(DIR_INSTALL) $(wildcard $(srcdir)/$(dir)/*) $(testxpcobjdir)/$(relativesrcdir)/$(dir)
-
-endef # do not remove the blank line!
-
-SOLO_FILE ?= $(error Specify a test filename in SOLO_FILE when using check-interactive or check-one)
-
-libs::
-	$(foreach dir,$(XPCSHELL_TESTS),$(_INSTALL_TESTS))
-ifndef NO_XPCSHELL_MANIFEST_CHECK
-	$(PYTHON) $(MOZILLA_DIR)/build/xpccheck.py \
-	  $(topsrcdir) \
-	  $(topsrcdir)/testing/xpcshell/xpcshell.ini \
-	  $(addprefix $(MOZILLA_DIR)/$(relativesrcdir)/,$(XPCSHELL_TESTS))
-endif
-
-testxpcsrcdir = $(topsrcdir)/testing/xpcshell
-
-# Execute all tests in the $(XPCSHELL_TESTS) directories.
-# See also testsuite-targets.mk 'xpcshell-tests' target for global execution.
-xpcshell-tests:
-	$(PYTHON) -u $(topsrcdir)/config/pythonpath.py \
-	  -I$(topsrcdir)/build -I$(DEPTH)/_tests/mozbase/mozinfo \
-	  $(testxpcsrcdir)/runxpcshelltests.py \
-	  --symbols-path=$(DIST)/crashreporter-symbols \
-	  --build-info-json=$(DEPTH)/mozinfo.json \
-	  --tests-root-dir=$(testxpcobjdir) \
-	  --testing-modules-dir=$(DEPTH)/_tests/modules \
-	  --xunit-file=$(testxpcobjdir)/$(relativesrcdir)/results.xml \
-	  --xunit-suite-name=xpcshell \
-	  $(EXTRA_TEST_ARGS) \
-	  $(LIBXUL_DIST)/bin/xpcshell \
-	  $(foreach dir,$(XPCSHELL_TESTS),$(testxpcobjdir)/$(relativesrcdir)/$(dir))
-
-xpcshell-tests-remote: DM_TRANS?=adb
-xpcshell-tests-remote:
-	$(PYTHON) -u $(topsrcdir)/config/pythonpath.py \
-	  -I$(topsrcdir)/build \
-	  -I$(topsrcdir)/build/mobile \
-	  $(topsrcdir)/testing/xpcshell/remotexpcshelltests.py \
-	  --symbols-path=$(DIST)/crashreporter-symbols \
-	  --build-info-json=$(DEPTH)/mozinfo.json \
-	  $(EXTRA_TEST_ARGS) \
-	  --dm_trans=$(DM_TRANS) \
-	  --deviceIP=${TEST_DEVICE} \
-	  --objdir=$(DEPTH) \
-	  $(foreach dir,$(XPCSHELL_TESTS),$(testxpcobjdir)/$(relativesrcdir)/$(dir))
-
-# Execute a single test, specified in $(SOLO_FILE), but don't automatically
-# start the test. Instead, present the xpcshell prompt so the user can
-# attach a debugger and then start the test.
-check-interactive:
-	$(PYTHON) -u $(topsrcdir)/config/pythonpath.py \
-	  -I$(topsrcdir)/build -I$(DEPTH)/_tests/mozbase/mozinfo \
-	  $(testxpcsrcdir)/runxpcshelltests.py \
-	  --symbols-path=$(DIST)/crashreporter-symbols \
-	  --build-info-json=$(DEPTH)/mozinfo.json \
-	  --test-path=$(SOLO_FILE) \
-	  --testing-modules-dir=$(DEPTH)/_tests/modules \
-	  --profile-name=$(MOZ_APP_NAME) \
-	  --interactive \
-	  $(LIBXUL_DIST)/bin/xpcshell \
-	  $(foreach dir,$(XPCSHELL_TESTS),$(testxpcobjdir)/$(relativesrcdir)/$(dir))
-
-# Execute a single test, specified in $(SOLO_FILE)
-check-one:
-	$(PYTHON) -u $(topsrcdir)/config/pythonpath.py \
-	  -I$(topsrcdir)/build -I$(DEPTH)/_tests/mozbase/mozinfo \
-	  $(testxpcsrcdir)/runxpcshelltests.py \
-	  --symbols-path=$(DIST)/crashreporter-symbols \
-	  --build-info-json=$(DEPTH)/mozinfo.json \
-	  --test-path=$(SOLO_FILE) \
-	  --testing-modules-dir=$(DEPTH)/_tests/modules \
-	  --profile-name=$(MOZ_APP_NAME) \
-	  --verbose \
-	  $(EXTRA_TEST_ARGS) \
-	  $(LIBXUL_DIST)/bin/xpcshell \
-	  $(foreach dir,$(XPCSHELL_TESTS),$(testxpcobjdir)/$(relativesrcdir)/$(dir))
-
-check-one-remote: DM_TRANS?=adb
-check-one-remote:
-	$(PYTHON) -u $(topsrcdir)/config/pythonpath.py \
-	  -I$(topsrcdir)/build \
-	  -I$(topsrcdir)/build/mobile \
-	  $(testxpcsrcdir)/remotexpcshelltests.py \
-	  --symbols-path=$(DIST)/crashreporter-symbols \
-	  --build-info-json=$(DEPTH)/mozinfo.json \
-	  --test-path=$(SOLO_FILE) \
-	  --profile-name=$(MOZ_APP_NAME) \
-	  --verbose \
-	  $(EXTRA_TEST_ARGS) \
-	  --dm_trans=$(DM_TRANS) \
-	  --deviceIP=${TEST_DEVICE} \
-	  --objdir=$(DEPTH) \
-          --noSetup \
-	  $(foreach dir,$(XPCSHELL_TESTS),$(testxpcobjdir)/$(relativesrcdir)/$(dir))
-endif # XPCSHELL_TESTS
+ifndef INCLUDED_TESTS_XPCSHELL_MK #{
+  include $(topsrcdir)/config/makefiles/xpcshell.mk
+endif #}
 
 ifdef CPP_UNIT_TESTS
 
 # Compile the tests to $(DIST)/bin.  Make lots of niceties available by default
 # through TestHarness.h, by modifying the list of includes and the libs against
 # which stuff links.
 CPPSRCS += $(CPP_UNIT_TESTS)
 SIMPLE_PROGRAMS += $(CPP_UNIT_TESTS:.cpp=$(BIN_SUFFIX))
@@ -202,17 +103,17 @@ LIBS += $(XPCOM_GLUE_LDOPTS) $(NSPR_LIBS
 check::
 	@$(EXIT_ON_ERROR) \
 	  for f in $(subst .cpp,$(BIN_SUFFIX),$(CPP_UNIT_TESTS)); do \
 	    XPCOM_DEBUG_BREAK=stack-and-abort $(RUN_TEST_PROGRAM) $(DIST)/bin/$$f; \
 	  done
 
 endif # CPP_UNIT_TESTS
 
-.PHONY: check xpcshell-tests check-interactive check-one
+.PHONY: check
 
 endif # ENABLE_TESTS
 
 
 #
 # Library rules
 #
 # If FORCE_STATIC_LIB is set, build a static library.
@@ -1370,16 +1271,17 @@ ifneq ($(AUTOCFG_JS_EXPORTS),)
 	$(NSINSTALL) -D $@
 
 ifndef NO_DIST_INSTALL
 export:: $(AUTOCFG_JS_EXPORTS) $(FINAL_TARGET)/defaults/autoconfig
 	$(INSTALL) $(IFLAGS1) $^
 endif
 
 endif
+
 ################################################################################
 # Export the elements of $(XPIDLSRCS)
 # generating .h and .xpt files and moving them to the appropriate places.
 
 ifneq ($(XPIDLSRCS),)
 
 export:: $(patsubst %.idl,$(XPIDL_GEN_DIR)/%.h, $(XPIDLSRCS))
 
@@ -1843,116 +1745,22 @@ FORCE:
 
 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)
-
-echo-tier-dirs:
-	@$(foreach tier,$(TIERS),echo '$(tier):'; echo '  dirs: $(tier_$(tier)_dirs)'; echo '  staticdirs: $(tier_$(tier)_staticdirs)'; )
-
-echo-dirs:
-	@echo $(DIRS)
-
-echo-module:
-	@echo $(MODULE)
-
-echo-depth-path:
-	@$(topsrcdir)/build/unix/print-depth-path.sh
-
-echo-module-name:
-	@$(topsrcdir)/build/package/rpm/print-module-name.sh
-
-echo-module-filelist:
-	@$(topsrcdir)/build/package/rpm/print-module-filelist.sh
-
-showtargs:
-ifneq (,$(filter $(PROGRAM) $(HOST_PROGRAM) $(SIMPLE_PROGRAMS) $(HOST_LIBRARY) $(LIBRARY) $(SHARED_LIBRARY),$(TARGETS)))
-	@echo --------------------------------------------------------------------------------
-	@echo "PROGRAM             = $(PROGRAM)"
-	@echo "SIMPLE_PROGRAMS     = $(SIMPLE_PROGRAMS)"
-	@echo "LIBRARY             = $(LIBRARY)"
-	@echo "SHARED_LIBRARY      = $(SHARED_LIBRARY)"
-	@echo "SHARED_LIBRARY_LIBS = $(SHARED_LIBRARY_LIBS)"
-	@echo "LIBS                = $(LIBS)"
-	@echo "DEF_FILE            = $(DEF_FILE)"
-	@echo "IMPORT_LIBRARY      = $(IMPORT_LIBRARY)"
-	@echo "STATIC_LIBS         = $(STATIC_LIBS)"
-	@echo "SHARED_LIBS         = $(SHARED_LIBS)"
-	@echo "EXTRA_DSO_LIBS      = $(EXTRA_DSO_LIBS)"
-	@echo "EXTRA_DSO_LDOPTS    = $(EXTRA_DSO_LDOPTS)"
-	@echo "DEPENDENT_LIBS      = $(DEPENDENT_LIBS)"
-	@echo --------------------------------------------------------------------------------
-endif
-	$(LOOP_OVER_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)"
-	@echo "CPP                = $(CPP)"
-	@echo "LD                 = $(LD)"
-	@echo "AR                 = $(AR)"
-	@echo "IMPLIB             = $(IMPLIB)"
-	@echo "FILTER             = $(FILTER)"
-	@echo "MKSHLIB            = $(MKSHLIB)"
-	@echo "MKCSHLIB           = $(MKCSHLIB)"
-	@echo "RC                 = $(RC)"
-	@echo "MC                 = $(MC)"
-	@echo "CFLAGS             = $(CFLAGS)"
-	@echo "OS_CFLAGS          = $(OS_CFLAGS)"
-	@echo "COMPILE_CFLAGS     = $(COMPILE_CFLAGS)"
-	@echo "CXXFLAGS           = $(CXXFLAGS)"
-	@echo "OS_CXXFLAGS        = $(OS_CXXFLAGS)"
-	@echo "COMPILE_CXXFLAGS   = $(COMPILE_CXXFLAGS)"
-	@echo "COMPILE_CMFLAGS    = $(COMPILE_CMFLAGS)"
-	@echo "COMPILE_CMMFLAGS   = $(COMPILE_CMMFLAGS)"
-	@echo "LDFLAGS            = $(LDFLAGS)"
-	@echo "OS_LDFLAGS         = $(OS_LDFLAGS)"
-	@echo "DSO_LDOPTS         = $(DSO_LDOPTS)"
-	@echo "OS_INCLUDES        = $(OS_INCLUDES)"
-	@echo "OS_LIBS            = $(OS_LIBS)"
-	@echo "EXTRA_LIBS         = $(EXTRA_LIBS)"
-	@echo "BIN_FLAGS          = $(BIN_FLAGS)"
-	@echo "INCLUDES           = $(INCLUDES)"
-	@echo "DEFINES            = $(DEFINES)"
-	@echo "ACDEFINES          = $(ACDEFINES)"
-	@echo "BIN_SUFFIX         = $(BIN_SUFFIX)"
-	@echo "LIB_SUFFIX         = $(LIB_SUFFIX)"
-	@echo "DLL_SUFFIX         = $(DLL_SUFFIX)"
-	@echo "IMPORT_LIB_SUFFIX  = $(IMPORT_LIB_SUFFIX)"
-	@echo "INSTALL            = $(INSTALL)"
-	@echo "VPATH              = $(VPATH)"
-
-showhost:
-	@echo "HOST_CC            = $(HOST_CC)"
-	@echo "HOST_CXX           = $(HOST_CXX)"
-	@echo "HOST_CFLAGS        = $(HOST_CFLAGS)"
-	@echo "HOST_LDFLAGS       = $(HOST_LDFLAGS)"
-	@echo "HOST_LIBS          = $(HOST_LIBS)"
-	@echo "HOST_EXTRA_LIBS    = $(HOST_EXTRA_LIBS)"
-	@echo "HOST_EXTRA_DEPS    = $(HOST_EXTRA_DEPS)"
-	@echo "HOST_PROGRAM       = $(HOST_PROGRAM)"
-	@echo "HOST_OBJS          = $(HOST_OBJS)"
-	@echo "HOST_PROGOBJS      = $(HOST_PROGOBJS)"
-	@echo "HOST_LIBRARY       = $(HOST_LIBRARY)"
-
-showbuildmods::
-	@echo "Module dirs	= $(BUILD_MODULE_DIRS)"
+ifndef INCLUDED_DEBUGMAKE_MK #{
+  ## Only parse when an echo* or show* target is requested
+  ifneq (,$(call isTargetStem,echo,show))
+    include $(topsrcdir)/config/makefiles/debugmake.mk
+  endif #}
+endif #}
 
 documentation:
 	@cd $(DEPTH)
 	$(DOXYGEN) $(DEPTH)/config/doxygen.cfg
 
 ifdef ENABLE_TESTS
 check:: $(SUBMAKEFILES) $(MAKE_DIRS)
 	$(LOOP_OVER_PARALLEL_DIRS)