WiP TODO -- make c-c a subdir under m-c draft
authorPhilipp Kewisch <mozilla@kewis.ch>
Sun, 26 Feb 2017 16:45:39 +0100
changeset 50099 917c4b2f3af1530cd2e3517b3b8454e659b638d9
parent 49887 a4943acf76146f25dc5d2adb4826767ea3e47ffa
child 50100 a7d3c94963604efb2ae64acd45ef6a51c05f26ec
push id4546
push usermozilla@kewis.ch
push dateMon, 15 May 2017 10:56:03 +0000
treeherdertry-comm-central@a7d3c9496360 [default view] [failures only]
WiP TODO -- make c-c a subdir under m-c MozReview-Commit-ID: DhZnUDM0EyZ
calendar/.eslintrc.js
calendar/libical/src/libical/Makefile.in
calendar/lightning/Makefile.in
calendar/lightning/jar.mn
calendar/lightning/lightning-packager.mk
calendar/lightning/lightning-tests.mk
calendar/lightning/locales/Makefile.in
calendar/lightning/versions.mk
calendar/providers/gdata/Makefile.in
calendar/providers/gdata/locales/Makefile.in
calendar/test/mozmill/Makefile.in
calendar/timezones/Makefile.in
im/Makefile.in
im/app/Makefile.in
im/app/moz.build
im/branding/halloween/Makefile.in
im/branding/nightly/Makefile.in
im/build.mk
im/configure.in
im/content/jar.mn
im/content/moz.build
im/installer/Makefile.in
im/installer/windows/Makefile.in
im/locales/Makefile.in
ldap/c-sdk/libraries/liblber/moz.build
ldap/c-sdk/libraries/libldap/moz.build
ldap/c-sdk/libraries/libldif/moz.build
ldap/c-sdk/libraries/libprldap/moz.build
ldap/xpcom/src/moz.build
mail/Makefile.in
mail/app.mozbuild
mail/app/Makefile.in
mail/app/moz.build
mail/app/profile/extensions/Makefile.in
mail/base/jar.mn
mail/base/moz.build
mail/branding/aurora/Makefile.in
mail/branding/nightly/Makefile.in
mail/build.mk
mail/components/search/mdimporter/Makefile.in
mail/configure.in
mail/confvars.sh
mail/extensions/smime/jar.mn
mail/installer/Makefile.in
mail/installer/windows/Makefile.in
mail/locales/Makefile.in
mail/moz.build
mail/test/mozmill/Makefile.in
mail/test/mozmill/moz.build
mail/testsuite-targets.mk
mailnews/base/test/moz.build
mailnews/base/util/moz.build
mailnews/build/moz.build
mailnews/extensions/smime/src/moz.build
mailnews/imap/test/moz.build
mailnews/intl/moz.build
mailnews/jsaccount/test/idl/moz.build
mailnews/mailnews.mozbuild
mailnews/mime/src/moz.build
mailnews/moz.build
suite/Makefile.in
suite/app.mozbuild
suite/app/Makefile.in
suite/app/moz.build
suite/branding/nightly/Makefile.in
suite/browser/Makefile.in
suite/build/Makefile.in
suite/build/moz.build
suite/common/jar.mn
suite/common/moz.build
suite/configure.in
suite/confvars.sh
suite/installer/Makefile.in
suite/installer/windows/Makefile.in
suite/locales/Makefile.in
suite/moz.build
suite/themes/modern/jar.mn
suite/themes/modern/moz.build
--- a/calendar/.eslintrc.js
+++ b/calendar/.eslintrc.js
@@ -1,13 +1,13 @@
 "use strict";
 
 module.exports = {
     "extends": [
-        "../mozilla/toolkit/.eslintrc.js"
+        "../../toolkit/.eslintrc.js"
     ],
     "rules": {
         // Enforce one true brace style (opening brace on the same line)
         // Allow single line (for now) because of the vast number of changes needed
         "brace-style": [2, "1tbs", { allowSingleLine: true }],
 
         // Enforce newline at the end of file, with no multiple empty lines.
         "eol-last": 2,
--- a/calendar/libical/src/libical/Makefile.in
+++ b/calendar/libical/src/libical/Makefile.in
@@ -49,17 +49,17 @@ ical_TARGET := export
 
 CSRCS += \
 	icalderivedparameter.c \
 	icalderivedproperty.c \
 	icalderivedvalue.c \
 	icalrestriction.c \
 	$(NULL)
 
-include $(topsrcdir)/config/rules.mk
+include $(moztopsrcdir)/config/rules.mk
 
 ######################################################################
 #
 # Generate files that are automatically generated (*.h.in and *.c.in)
 # and ical.h
 #
 
 DESIGNDATA = $(srcdir)/../../design-data
--- a/calendar/lightning/Makefile.in
+++ b/calendar/lightning/Makefile.in
@@ -15,39 +15,39 @@ DEFINES += -DLIGHTNING_PRERELEASE_VERSIO
 endif
 
 # Enable nightly updates on nightly channel
 ifeq (nightly,$(MOZ_UPDATE_CHANNEL))
 DEFINES += -DLIGHTNING_UPDATE_LOCATION=https://calendar.mozilla.org/update.php
 endif
 
 # Gecko milestone
-GRE_MILESTONE = $(shell $(PYTHON) $(MOZILLA_SRCDIR)/config/printconfigsetting.py $(DIST)/bin/platform.ini Build Milestone)
+GRE_MILESTONE = $(shell $(PYTHON) $(moztopsrcdir)/config/printconfigsetting.py $(DIST)/bin/platform.ini Build Milestone)
 ifdef GRE_MILESTONE
 DEFINES += -DGRE_MILESTONE=$(GRE_MILESTONE)
 endif
 
 # comm-central source repo and stamp
-SOURCE_STAMP ?= $(firstword $(shell hg -R $(topsrcdir) parent --template='{node}\n' 2>/dev/null))
+SOURCE_STAMP ?= $(firstword $(shell hg -R $(commtopsrcdir) parent --template='{node}\n' 2>/dev/null))
 ifdef SOURCE_STAMP
 DEFINES += -DSOURCE_STAMP='$(SOURCE_STAMP)'
 endif
 
-SOURCE_REPO := $(shell hg -R $(topsrcdir) showconfig paths.default 2>/dev/null | sed -e 's/^ssh:/http:/')
+SOURCE_REPO := $(shell hg -R $(commtopsrcdir) showconfig paths.default 2>/dev/null | sed -e 's/^ssh:/http:/')
 ifdef SOURCE_REPO
 DEFINES += -DSOURCE_REPO='$(SOURCE_REPO)'
 endif
 
 # Mozilla source repo and stamps
-MOZ_SOURCE_STAMP = $(firstword $(shell hg -R $(MOZILLA_SRCDIR) parent --template='{node}\n' 2>/dev/null))
+MOZ_SOURCE_STAMP = $(firstword $(shell hg -R $(moztopsrcdir) parent --template='{node}\n' 2>/dev/null))
 ifdef MOZ_SOURCE_STAMP
 DEFINES += -DMOZ_SOURCE_STAMP='$(MOZ_SOURCE_STAMP)'
 endif
 
-MOZ_SOURCE_REPO := $(shell hg -R $(MOZILLA_SRCDIR) showconfig paths.default 2>/dev/null | sed -e 's/^ssh:/http:/')
+MOZ_SOURCE_REPO := $(shell hg -R $(moztopsrcdir) showconfig paths.default 2>/dev/null | sed -e 's/^ssh:/http:/')
 ifdef MOZ_SOURCE_REPO
 DEFINES += -DMOZ_SOURCE_REPO='$(MOZ_SOURCE_REPO)'
 endif
 
 ifdef NIGHTLY_BUILD
 # On nightly builds, install as a global extension in
 # dist/bin/extensions/
 XPI_INSTALL_EXTENSION = $(XPI_EM_ID)
@@ -60,34 +60,34 @@ endif
 DEFINES += -DTHUNDERBIRD_VERSION=$(THUNDERBIRD_VERSION) \
            -DTHUNDERBIRD_MAXVERSION=$(THUNDERBIRD_MAXVERSION) \
            -DSEAMONKEY_VERSION=$(SEAMONKEY_VERSION) \
            -DSEAMONKEY_MAXVERSION=$(SEAMONKEY_MAXVERSION) \
            -DLIGHTNING_VERSION=$(LIGHTNING_VERSION) \
            -DXPI_EM_ID="$(XPI_EM_ID)" \
            $(NULL)
 
-MOZ_BUILDID = $(shell $(PYTHON) $(MOZILLA_SRCDIR)/config/printconfigsetting.py $(DIST)/bin/application.ini App BuildID)
+MOZ_BUILDID = $(shell $(PYTHON) $(moztopsrcdir)/config/printconfigsetting.py $(DIST)/bin/application.ini App BuildID)
 DEFINES += -DMOZ_BUILDID=$(MOZ_BUILDID)
 
-include $(topsrcdir)/config/rules.mk
+include $(moztopsrcdir)/config/rules.mk
 include $(srcdir)/versions.mk
 include $(srcdir)/lightning-packager.mk
 include $(srcdir)/lightning-tests.mk
 
 # For Lightning, we also need to preprocess the l10n prefs. Pull in the en-US
 # copy if the files doesn't exist.
 repack-process-extrafiles: lightning-extrafiles
 lightning-extrafiles: LTN_ABCD_L10NJS=$(call EXPAND_LOCALE_SRCDIR,calendar/locales)/lightning-l10n.js
-lightning-extrafiles: LTN_ANY_L10NJS=$(if $(wildcard $(LTN_ABCD_L10NJS)),$(LTN_ABCD_L10NJS),$(topsrcdir)/calendar/locales/en-US/lightning-l10n.js)
+lightning-extrafiles: LTN_ANY_L10NJS=$(if $(wildcard $(LTN_ABCD_L10NJS)),$(LTN_ABCD_L10NJS),$(commtopsrcdir)/calendar/locales/en-US/lightning-l10n.js)
 lightning-extrafiles:
 	$(call py_action,preprocessor,$(PREF_PPFLAGS) $(DEFINES) $(ACDEFINES) $(XULPPFLAGS) $(LTN_ANY_L10NJS) -o $(DIST)/$(UNIVERSAL_PATH)xpi-stage/$(L10N_XPI_NAME)/$(PREF_DIR)/lightning-l10n.js)
 
 ident:
 	@printf 'comm_revision '
-	@$(PYTHON) $(MOZILLA_SRCDIR)/config/printconfigsetting.py \
+	@$(PYTHON) $(moztopsrcdir)/config/printconfigsetting.py \
 	    $(FINAL_TARGET)/app.ini App SourceStamp
 	@printf 'moz_revision '
-	@$(PYTHON) $(MOZILLA_SRCDIR)/config/printconfigsetting.py \
+	@$(PYTHON) $(moztopsrcdir)/config/printconfigsetting.py \
 	    $(FINAL_TARGET)/app.ini Build SourceStamp
 	@printf 'buildid '
-	@$(PYTHON) $(MOZILLA_SRCDIR)/config/printconfigsetting.py \
+	@$(PYTHON) $(moztopsrcdir)/config/printconfigsetting.py \
 	    $(FINAL_TARGET)/app.ini App BuildID
--- a/calendar/lightning/jar.mn
+++ b/calendar/lightning/jar.mn
@@ -99,22 +99,22 @@ lightning.jar:
     ../skin/windows/lightning/imip.css                        (themes/windows/imip.css)
     ../skin/windows/lightning/lightning.css                   (themes/windows/lightning.css)
     ../skin/windows/lightning/lightning-toolbar.css           (themes/windows/lightning-toolbar.css)
     ../skin/windows/lightning/lightning-widgets.css           (themes/windows/lightning-widgets.css)
     ../skin/windows/lightning/mode-switch-icons-aero.png      (themes/windows/images/mode-switch-icons-aero.png)
 
 
 calendar.jar:
-    content/calendar/calendarCreation.xul                  (/calendar/resources/content/calendarCreation.xul)
-    content/calendar/calendarCreation.js                   (/calendar/resources/content/calendarCreation.js)
-    content/calendar/datetimepickers/datetimepickers.css   (/calendar/resources/content/datetimepickers/datetimepickers.css)
-    content/calendar/datetimepickers/datetimepickers.xml   (/calendar/resources/content/datetimepickers/datetimepickers.xml)
-    content/calendar/mouseoverPreviews.js                  (/calendar/resources/content/mouseoverPreviews.js)
-    content/calendar/publish.js                            (/calendar/resources/content/publish.js)
-    content/calendar/publishDialog.js                      (/calendar/resources/content/publishDialog.js)
-    content/calendar/publishDialog.xul                     (/calendar/resources/content/publishDialog.xul)
-    content/calendar/sound.wav                             (/calendar/resources/content/sound.wav)
-    ../skin/lightning-common/datetimepickers.css           (/calendar/resources/skin/datetimepickers.css)
-    ../skin/lightning-common/dialogOverlay.css             (/calendar/resources/skin/dialogOverlay.css)
+    content/calendar/calendarCreation.xul                  (../resources/content/calendarCreation.xul)
+    content/calendar/calendarCreation.js                   (../resources/content/calendarCreation.js)
+    content/calendar/datetimepickers/datetimepickers.css   (../resources/content/datetimepickers/datetimepickers.css)
+    content/calendar/datetimepickers/datetimepickers.xml   (../resources/content/datetimepickers/datetimepickers.xml)
+    content/calendar/mouseoverPreviews.js                  (../resources/content/mouseoverPreviews.js)
+    content/calendar/publish.js                            (../resources/content/publish.js)
+    content/calendar/publishDialog.js                      (../resources/content/publishDialog.js)
+    content/calendar/publishDialog.xul                     (../resources/content/publishDialog.xul)
+    content/calendar/sound.wav                             (../resources/content/sound.wav)
+    ../skin/lightning-common/datetimepickers.css           (../resources/skin/datetimepickers.css)
+    ../skin/lightning-common/dialogOverlay.css             (../resources/skin/dialogOverlay.css)
     ../skin/lightning-common/imip.css                      (themes/common/imip.css)
     ../skin/lightning-common/lightning.css                 (themes/common/lightning.css)
     ../skin/lightning-common/html-item-editing.css         (themes/common/html-item-editing.css)
--- a/calendar/lightning/lightning-packager.mk
+++ b/calendar/lightning/lightning-packager.mk
@@ -15,17 +15,17 @@
 #
 # The following variables are optional:
 #   XPI_NO_UNIVERSAL = 1  # If set, no universal path is used on mac
 #
 # For the upload target to work, you also need to set:
 #   LIGHTNING_VERSION = 2.2  # Will be used to replace the Thunderbird version
 #   						 # in POST_UPLOAD_CMD
 
-include $(MOZILLA_SRCDIR)/toolkit/mozapps/installer/package-name.mk
+include $(moztopsrcdir)/toolkit/mozapps/installer/package-name.mk
 
 # Set the univeral path only if we are building a univeral binary and it was
 # not restricted by the calling makefile
 ifeq ($(UNIVERSAL_BINARY)|$(XPI_NO_UNIVERSAL),1|)
 UNIVERSAL_PATH=universal/
 else
 UNIVERSAL_PATH=
 endif
@@ -72,17 +72,17 @@ L10N_TARGET = $(XPI_STAGE_PATH)/$(XPI_NA
 # special case, so assume linux for everything else.
 ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
 SHORTOS = osx
 else
 SHORTOS = linux
 endif
 
 # function print_ltnconfig(section,configname)
-print_ltnconfig = $(shell $(PYTHON) $(MOZILLA_SRCDIR)/config/printconfigsetting.py $(XPI_STAGE_PATH)/$(XPI_NAME)/app.ini $1 $2)
+print_ltnconfig = $(shell $(PYTHON) $(moztopsrcdir)/config/printconfigsetting.py $(XPI_STAGE_PATH)/$(XPI_NAME)/app.ini $1 $2)
 
 wget-en-US:
 ifeq (thunderbird,$(MOZ_APP_NAME))
 FINAL_BINARY_URL = $(subst thunderbird,calendar/lightning,$(EN_US_BINARY_URL))
 else
 FINAL_BINARY_URL = $(subst seamonkey,calendar/lightning,$(subst latest-comm-central-trunk,latest-comm-central,$(EN_US_BINARY_URL)))
 endif
 wget-en-US: $(XPI_STAGE_PATH)
@@ -102,19 +102,19 @@ unpack: $(XPI_ZIP_IN)
 
 # Nothing to package for en-US, its just the usual english xpi
 langpack-en-US:
 	@echo "Skipping $@ as en-US is the default"
 
 merge-%:
 ifdef LOCALE_MERGEDIR
 	$(RM) -rf $(LOCALE_MERGEDIR)/calendar
-	$(MOZILLA_SRCDIR)/mach compare-locales \
+	$(moztopsrcdir)/mach compare-locales \
 	    --merge-dir $(LOCALE_MERGEDIR) \
-	    --l10n-ini $(topsrcdir)/calendar/locales/l10n.ini \
+	    --l10n-ini $(commtopsrcdir)/calendar/locales/l10n.ini \
 	    $*
 
 	# This file requires a bugfix with string changes, see bug 1154448
 	[ -f $(L10NBASEDIR)/$*/calendar/chrome/calendar/calendar-extract.properties ] && \
 	  $(RM) $(LOCALE_MERGEDIR)/calendar/chrome/calendar/calendar-extract.properties \
 	  || true
 else
 	@echo "Not merging Lightning locales due to missing LOCALE_MERGEDIR"
--- a/calendar/lightning/lightning-tests.mk
+++ b/calendar/lightning/lightning-tests.mk
@@ -13,11 +13,11 @@ stage-extension:
 	$(NSINSTALL) -D $(PKG_STAGE)/extensions/$(XPI_EM_ID)
 	(cd $(FINAL_TARGET) && tar $(TAR_CREATE_FLAGS) - *) | (cd $(PKG_STAGE)/extensions/$(XPI_EM_ID) && tar -xf -)
 	grep -v em:targetPlatform $(FINAL_TARGET)/install.rdf > $(PKG_STAGE)/extensions/$(XPI_EM_ID)/install.rdf
 
 # stage mozmill tests and shared modules. Cross your fingers that there are no
 # name conflicts between calendar/ and mail/
 stage-mozmill:
 	$(NSINSTALL) -D $(PKG_STAGE)/mozmill/shared-modules
-	(cd $(topsrcdir)/calendar/test/mozmill && tar $(TAR_CREATE_FLAGS) - `cat $(topsrcdir)/calendar/test/mozmill/mozmilltests.list`) | (cd $(PKG_STAGE)/mozmill && tar -xf -)
-	(cd $(topsrcdir)/calendar/test/mozmill/shared-modules && tar $(TAR_CREATE_FLAGS) - *) | (cd $(PKG_STAGE)/mozmill/shared-modules && tar -xf -)
-	$(call py_action,buildlist,$(PKG_STAGE)/mozmill/mozmilltests.list $(shell cat $(topsrcdir)/calendar/test/mozmill/mozmilltests.list))
+	(cd $(commtopsrcdir)/calendar/test/mozmill && tar $(TAR_CREATE_FLAGS) - `cat $(commtopsrcdir)/calendar/test/mozmill/mozmilltests.list`) | (cd $(PKG_STAGE)/mozmill && tar -xf -)
+	(cd $(commtopsrcdir)/calendar/test/mozmill/shared-modules && tar $(TAR_CREATE_FLAGS) - *) | (cd $(PKG_STAGE)/mozmill/shared-modules && tar -xf -)
+	$(call py_action,buildlist,$(PKG_STAGE)/mozmill/mozmilltests.list $(shell cat $(commtopsrcdir)/calendar/test/mozmill/mozmilltests.list))
--- a/calendar/lightning/locales/Makefile.in
+++ b/calendar/lightning/locales/Makefile.in
@@ -1,11 +1,11 @@
 # 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/.
 
 # Setting this to calendar/locales sets up LOCALE_SRCDIR to the correct locale
 # directory
-relativesrcdir = calendar/locales
+relativesrcdir = $(commreltopsrcdir)/calendar/locales
 
 DEFINES += -DTHEME=$(THEME) \
            -DLOCALE_SRCDIR=$(LOCALE_SRCDIR) \
            $(NULL)
--- a/calendar/lightning/versions.mk
+++ b/calendar/lightning/versions.mk
@@ -1,23 +1,23 @@
 # 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/.
 
 # Lighting version number
-THUNDERBIRD_VERSION := $(shell cat $(topsrcdir)/mail/config/version.txt)
-SEAMONKEY_VERSION := $(shell cat $(topsrcdir)/suite/config/version.txt)
+THUNDERBIRD_VERSION := $(shell cat $(commtopsrcdir)/mail/config/version.txt)
+SEAMONKEY_VERSION := $(shell cat $(commtopsrcdir)/suite/config/version.txt)
 
 ifdef MOZ_SUITE
-LIGHTNING_VERSION := $(shell $(PYTHON) $(topsrcdir)/calendar/lightning/build/makeversion.py $(THUNDERBIRD_VERSION))
+LIGHTNING_VERSION := $(shell $(PYTHON) $(commtopsrcdir)/calendar/lightning/build/makeversion.py $(THUNDERBIRD_VERSION))
 else
-LIGHTNING_VERSION := $(shell $(PYTHON) $(topsrcdir)/calendar/lightning/build/makeversion.py $(word 1,$(MOZ_PKG_VERSION) $(THUNDERBIRD_VERSION)))
+LIGHTNING_VERSION := $(shell $(PYTHON) $(commtopsrcdir)/calendar/lightning/build/makeversion.py $(word 1,$(MOZ_PKG_VERSION) $(THUNDERBIRD_VERSION)))
 endif
 
-GDATA_VERSION := $(shell $(PYTHON) $(topsrcdir)/calendar/providers/gdata/makeversion.py $(LIGHTNING_VERSION))
+GDATA_VERSION := $(shell $(PYTHON) $(commtopsrcdir)/calendar/providers/gdata/makeversion.py $(LIGHTNING_VERSION))
 
 # For extensions we require a max version that is compatible across security releases.
 # THUNDERBIRD_MAXVERSION and SEAMONKEY_MAXVERSION is our method for doing that.
 # Alpha versions 10.0a1 and 10.0a2 aren't affected
 # For Seamonkey, 2.17 becomes 2.17.*, 2.17.1 becomes 2.17.*
 # For Thunderbird, 10.0 becomes 10.*, 10.0.1 becomes 10.*
 THUNDERBIRD_MAXVERSION := $(THUNDERBIRD_VERSION)
 ifneq (a,$(findstring a,$(THUNDERBIRD_VERSION)))
--- a/calendar/providers/gdata/Makefile.in
+++ b/calendar/providers/gdata/Makefile.in
@@ -24,11 +24,11 @@ endif
 
 # stage the extension for use in packaged tests
 PKG_STAGE = $(DIST)/test-stage
 
 stage-package:
 	$(NSINSTALL) -D $(PKG_STAGE)/extensions/$(XPI_EM_ID)
 	(cd $(FINAL_TARGET) && tar $(TAR_CREATE_FLAGS) - *) | (cd $(PKG_STAGE)/extensions/$(XPI_EM_ID) && tar -xf -)
 
-include $(topsrcdir)/config/rules.mk
-include $(topsrcdir)/calendar/lightning/versions.mk
-include $(topsrcdir)/calendar/lightning/lightning-packager.mk
+include $(moztopsrcdir)/config/rules.mk
+include $(commtopsrcdir)/calendar/lightning/versions.mk
+include $(commtopsrcdir)/calendar/lightning/lightning-packager.mk
--- a/calendar/providers/gdata/locales/Makefile.in
+++ b/calendar/providers/gdata/locales/Makefile.in
@@ -1,9 +1,9 @@
 # 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/.
 
 # Setting this to calendar/locales sets up LOCALE_SRCDIR to the correct locale
 # directory
-relativesrcdir = calendar/locales
+relativesrcdir = $(commreltopsrcdir)/calendar/locales
 
 DEFINES += -DLOCALE_SRCDIR=$(LOCALE_SRCDIR)
--- a/calendar/test/mozmill/Makefile.in
+++ b/calendar/test/mozmill/Makefile.in
@@ -20,30 +20,30 @@ MOZMILLPROGRAM = $(ABS_DIST)/$(APP_NAME)
 else
 # Non-mac options
 MOZMILLPROGRAM = $(ABS_DIST)/bin/thunderbird$(BIN_SUFFIX)
 endif
 
 check-no-solo = $(foreach solo,SOLO_TEST SOLO_FILE,$(if $($(solo)),$(error $(subst SOLOVAR,$(solo),$(1)))))
 find-solo-test = $(if $(and $(SOLO_TEST),$(SOLO_FILE)),$(error Both SOLO_TEST and SOLO_FILE are specified. You may only specify one.),$(if $(SOLO_TEST),$(SOLO_TEST),$(if $(SOLO_FILE),$(SOLO_FILE),$(error SOLO_TEST or SOLO_FILE needs to be specified.))))
 
-include $(topsrcdir)/config/rules.mk
+include $(moztopsrcdir)/config/rules.mk
 
 # Calendar uses both its own shared modules and those from Thunderbird. Since
 # the build system and mozmill is not set up to include files from two different
 # locations, we have to stuff them into the same directory. There might be
 # problems if the names are the same, but I propose we boycott those modules!
 mozmill-stage: MOZMILL_STAGE=$(MOZMILLDIR)/stage
 mozmill-stage: MOZMILL_STAGE_SHARED=$(MOZMILL_STAGE)/shared-modules
 mozmill-stage: $(MOZMILL_SHARED)
 	$(INSTALL) -D $(MOZMILL_STAGE)
 	$(INSTALL) -D $(MOZMILL_STAGE_SHARED)
 	$(INSTALL) $(addprefix $(srcdir)/,$(shell cat $(srcdir)/mozmilltests.list)) $(MOZMILL_STAGE)
 
-	$(INSTALL) $(wildcard $(topsrcdir)/mail/test/mozmill/shared-modules/*.js) $(MOZMILL_STAGE_SHARED)
+	$(INSTALL) $(wildcard $(commtopsrcdir)/mail/test/mozmill/shared-modules/*.js) $(MOZMILL_STAGE_SHARED)
 	$(INSTALL) $(wildcard $(srcdir)/shared-modules/*.js) $(MOZMILL_STAGE_SHARED)
 
 mozmill: mozmill-stage
 	unset PYTHONHOME && cd $(MOZMILLDIR) && unset MACOSX_DEPLOYMENT_TARGET && \
 	$(MOZMILLPYTHON) runtestlist.py --list=$(srcdir)/mozmilltests.list \
 	--binary=$(MOZMILLPROGRAM) \
 	--dir=$(abspath $(MOZMILLDIR))/stage \
 	--symbols-path=$(ABS_DIST)/crashreporter-symbols \
--- a/calendar/timezones/Makefile.in
+++ b/calendar/timezones/Makefile.in
@@ -1,20 +1,20 @@
 # 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/.
 
 XPI_PKGNAME = calendar-timezones-$(TIMEZONES_VERSION)
 
-THUNDERBIRD_VERSION := $(shell cat $(topsrcdir)/mail/config/version.txt)
-SEAMONKEY_VERSION := $(shell cat $(topsrcdir)/suite/config/version.txt)
-CALENDAR_VERSION := $(shell $(PYTHON) $(topsrcdir)/calendar/lightning/build/makeversion.py $(word 1,$(MOZ_PKG_VERSION) $(THUNDERBIRD_VERSION)))
+THUNDERBIRD_VERSION := $(shell cat $(commtopsrcdir)/mail/config/version.txt)
+SEAMONKEY_VERSION := $(shell cat $(commtopsrcdir)/suite/config/version.txt)
+CALENDAR_VERSION := $(shell $(PYTHON) $(commtopsrcdir)/calendar/lightning/build/makeversion.py $(word 1,$(MOZ_PKG_VERSION) $(THUNDERBIRD_VERSION)))
 TIMEZONES_VERSION := $(shell $(PYTHON) $(srcdir)/version.py)
 
-relativesrcdir = calendar/locales
+relativesrcdir = $(commreltopsrcdir)/calendar/locales
 
 DEFINES += -DTHUNDERBIRD_VERSION=$(THUNDERBIRD_VERSION) \
            -DSEAMONKEY_VERSION=$(SEAMONKEY_VERSION) \
            -DCALENDAR_VERSION=$(CALENDAR_VERSION) \
            -DTIMEZONES_VERSION=$(TIMEZONES_VERSION) \
            $(NULL)
 
 libs-%:
--- a/im/Makefile.in
+++ b/im/Makefile.in
@@ -1,25 +1,25 @@
 #
 # 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/.
 
-include $(topsrcdir)/config/rules.mk
+include $(moztopsrcdir)/config/rules.mk
 
 ifdef MAKENSISU
 # For Windows build the uninstaller during the application build since the
 # uninstaller is included with the application for mar file generation.
 libs::
 	$(MAKE) -C installer/windows uninstaller
 endif
 
 
 # As a fallout from bug 1247162, the sourcestamp in application.ini and
 # platform.ini are the same, which isn't a problem for Firefox, but
 # it's not right for anything else. So we correct platform.ini here.
 
-MOZ_REV=$(shell hg -R "$(MOZILLA_SRCDIR)" parent --template="{node}" 2>/dev/null)
+MOZ_REV=$(shell hg -R "$(moztopsrcdir)" parent --template="{node}" 2>/dev/null)
 
 libs:: $(DIST)/bin/platform.ini
 	sed -e "s/^\(SourceStamp=\).*/\1$(MOZ_REV)/" $(DIST)/bin/platform.ini \
 		> $(DIST)/bin/platform.ini~
 	mv -f $(DIST)/bin/platform.ini~ $(DIST)/bin/platform.ini
--- a/im/app/Makefile.in
+++ b/im/app/Makefile.in
@@ -1,18 +1,18 @@
 # 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/.
 
 AB_CD = $(MOZ_UI_LOCALE)
 
-GRE_MILESTONE = $(shell $(PYTHON) $(MOZILLA_SRCDIR)/config/printconfigsetting.py $(DIST)/bin/platform.ini Build Milestone)
-MOZ_BUILDID = $(shell $(PYTHON) $(MOZILLA_SRCDIR)/config/printconfigsetting.py $(DIST)/bin/platform.ini Build BuildID)
+GRE_MILESTONE = $(shell $(PYTHON) $(moztopsrcdir)/config/printconfigsetting.py $(DIST)/bin/platform.ini Build Milestone)
+MOZ_BUILDID = $(shell $(PYTHON) $(moztopsrcdir)/config/printconfigsetting.py $(DIST)/bin/platform.ini Build BuildID)
 
-LICENSE_TXT_FILE = $(topsrcdir)/im/LICENSE.txt
+LICENSE_TXT_FILE = $(commtopsrcdir)/im/LICENSE.txt
 
 DEFINES += \
   -DINSTANTBIRD_ICO=\"$(DIST)/branding/instantbird.ico\" \
    $(NULL)
 
 # Build a binary bootstrapping with XRE_main
 
 ifndef MOZ_WINCONSOLE
@@ -22,53 +22,53 @@ else
 MOZ_WINCONSOLE = 0
 endif
 endif
 
 # This switches $(INSTALL) to copy mode, like $(SYSINSTALL), so things that
 # shouldn't get 755 perms need $(IFLAGS1) for either way of calling nsinstall.
 NSDISTMODE = copy
 
-include $(topsrcdir)/config/config.mk
+include $(moztopsrcdir)/config/config.mk
 
 # If we are trying to show an error dialog about the lack of SSE2 support,
 # make sure that code itself doesn't use SSE2.
 ifdef MOZ_LINUX_32_SSE2_STARTUP_ERROR
 CXXFLAGS := $(filter-out -march=% -msse -msse2 -mfpmath=sse,$(CXXFLAGS))
 CXX := $(filter-out -march=% -msse -msse2 -mfpmath=sse,$(CXX))
 CXXFLAGS += -mno-sse -mno-sse2 -mfpmath=387
 CXX += -march=pentiumpro
 endif
 
 ifeq ($(OS_ARCH),WINNT)
 # png to ico converter. The function takes 5 arguments, in order: source png
 # file, left, top, size, output ico file.
 png2ico = $(PYTHON) $(srcdir)/png2ico.py $(1) $(2) $(3) $(4) $(5)
 
 # Extract the icons we care about embedding into the EXE
-available-16.ico: $(topsrcdir)/chat/themes/available-16.png $(srcdir)/png2ico.py
-	$(call png2ico,$(topsrcdir)/chat/themes/available-16.png,0,0,16,available-16.ico)
+available-16.ico: $(commtopsrcdir)/chat/themes/available-16.png $(srcdir)/png2ico.py
+	$(call png2ico,$(commtopsrcdir)/chat/themes/available-16.png,0,0,16,available-16.ico)
 
-away-16.ico: $(topsrcdir)/chat/themes/away-16.png $(srcdir)/png2ico.py
-	$(call png2ico,$(topsrcdir)/chat/themes/away-16.png,0,0,16,away-16.ico)
+away-16.ico: $(commtopsrcdir)/chat/themes/away-16.png $(srcdir)/png2ico.py
+	$(call png2ico,$(commtopsrcdir)/chat/themes/away-16.png,0,0,16,away-16.ico)
 
-offline-16.ico: $(topsrcdir)/chat/themes/offline-16.png $(srcdir)/png2ico.py
-	$(call png2ico,$(topsrcdir)/chat/themes/offline-16.png,0,0,16,offline-16.ico)
+offline-16.ico: $(commtopsrcdir)/chat/themes/offline-16.png $(srcdir)/png2ico.py
+	$(call png2ico,$(commtopsrcdir)/chat/themes/offline-16.png,0,0,16,offline-16.ico)
 
 embedded-icons:: available-16.ico away-16.ico offline-16.ico
 GARBAGE += available-16.ico away-16.ico offline-16.ico
 
 # Rebuild instantbird.exe if the manifest changes - it's included by splash.rc.
 # (this dependency should really be just for instantbird.exe, not other targets)
 # Note the manifest file exists in the tree, so we use the explicit filename
 # here.
 EXTRA_DEPS += instantbird.exe.manifest
 endif
 
-include $(topsrcdir)/config/rules.mk
+include $(moztopsrcdir)/config/rules.mk
 
 ifeq ($(OS_ARCH),WINNT)
 
 $(RESFILE): embedded-icons
 
 endif
 
 ifneq ($(OS_ARCH),WINNT)
@@ -169,21 +169,21 @@ GARBAGE += module.ver
 libs:: $(srcdir)/profile/prefs.js
 	$(INSTALL) $(IFLAGS1) $^ $(DIST)/bin/defaults/profile
 
 ifdef ENABLE_TESTS
 # XXX This is a hack to ensure that we get the right xpcshell.ini for our tests.
 # mozilla-central does this in testing/xpcshell-tests which means that it is very
 # hard for anyone to specify anything else.
 libs::
-	$(INSTALL) $(IFLAGS1) $(topsrcdir)/im/test/xpcshell.ini $(DEPTH)/_tests/xpcshell
-	cp $(topsrcdir)/im/test/xpcshell.ini $(DEPTH)/_tests/xpcshell/all-test-dirs.list
+	$(INSTALL) $(IFLAGS1) $(commtopsrcdir)/im/test/xpcshell.ini $(DEPTH)/_tests/xpcshell
+	cp $(commtopsrcdir)/im/test/xpcshell.ini $(DEPTH)/_tests/xpcshell/all-test-dirs.list
 endif
 
-libs:: $(topsrcdir)/mail/app/blocklist.xml
+libs:: $(commtopsrcdir)/mail/app/blocklist.xml
 	$(INSTALL) $(IFLAGS1) $^ $(DIST)/bin
 
 ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
 
 MAC_APP_NAME = $(MOZ_APP_DISPLAYNAME)
 
 ifdef MOZ_DEBUG
 MAC_APP_NAME := $(MAC_APP_NAME)Debug
--- a/im/app/moz.build
+++ b/im/app/moz.build
@@ -5,36 +5,36 @@
 
 DIRS += ['profile']
 
 GeckoProgram(CONFIG['MOZ_APP_NAME'])
 USE_LIBS += ['mozglue']
 SOURCES += ['nsMain.cpp']
 LOCAL_INCLUDES += [
     '!/build',
-    '/mozilla/toolkit/xre',
-    '/mozilla/xpcom/base',
-    '/mozilla/xpcom/build',
+    '/%s/toolkit/xre' % CONFIG['mozreltopsrcdir'],
+    '/%s/xpcom/base' % CONFIG['mozreltopsrcdir'],
+    '/%s/xpcom/build' % CONFIG['mozreltopsrcdir'],
 ]
 
 if CONFIG['LIBFUZZER']:
     USE_LIBS += [ 'fuzzer' ]
     LOCAL_INCLUDES += [
-        '/mozilla/tools/fuzzing/libfuzzer',
+        '/%s/tools/fuzzing/libfuzzer' % CONFIG['mozreltopsrcdir'],
     ]
 
 if CONFIG['OS_ARCH'] == 'WINNT':
     RCINCLUDE = 'splash.rc'
     DEFINES['MOZ_INSTANTBIRD'] = True
 
 if CONFIG['MOZ_SANDBOX'] and CONFIG['OS_ARCH'] == 'WINNT':
     # For sandbox includes and the include dependencies those have
     LOCAL_INCLUDES += [
-        '/mozilla/security/sandbox/chromium',
-        '/mozilla/security/sandbox/chromium-shim',
+        '/%s/security/sandbox/chromium' % CONFIG['mozreltopsrcdir'],
+        '/%s/security/sandbox/chromium-shim' % CONFIG['mozreltopsrcdir'],
     ]
 
     USE_LIBS += [
         'sandbox_s',
     ]
 
     DELAYLOAD_DLLS += [
         'winmm.dll',
--- a/im/branding/halloween/Makefile.in
+++ b/im/branding/halloween/Makefile.in
@@ -1,15 +1,15 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 # Branding Makefile for nightlies/unofficial branding
 
-include $(topsrcdir)/config/rules.mk
+include $(moztopsrcdir)/config/rules.mk
 
 export::
 	$(NSINSTALL) -D $(DIST)/branding
 ifeq ($(OS_ARCH),WINNT)
 	cp $(srcdir)/instantbird.ico   $(DIST)/branding/instantbird.ico
 	cp $(srcdir)/instantbird.ico   $(DIST)/branding/app.ico
 	cp $(srcdir)/branding.nsi      $(DIST)/branding/branding.nsi
 	cp $(srcdir)/../nightly/wizHeader.bmp     $(DIST)/branding/wizHeader.bmp
--- a/im/branding/nightly/Makefile.in
+++ b/im/branding/nightly/Makefile.in
@@ -1,15 +1,15 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 # Branding Makefile for nightlies/unofficial branding
 
-include $(topsrcdir)/config/rules.mk
+include $(moztopsrcdir)/config/rules.mk
 
 export::
 	$(NSINSTALL) -D $(DIST)/branding
 ifeq ($(OS_ARCH),WINNT)
 	cp $(srcdir)/instantbird.ico   $(DIST)/branding/instantbird.ico
 	cp $(srcdir)/instantbird.ico   $(DIST)/branding/app.ico
 	cp $(srcdir)/branding.nsi      $(DIST)/branding/branding.nsi
 	cp $(srcdir)/wizHeader.bmp     $(DIST)/branding/wizHeader.bmp
--- a/im/build.mk
+++ b/im/build.mk
@@ -1,19 +1,19 @@
 # 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 COMM_BUILD
 
 ifndef MOZILLA_DIR
-MOZILLA_DIR = $(topsrcdir)
+MOZILLA_DIR = $(moztopsrcdir)
 endif
 # included to get $(BUILDID), which needs $(MOZILLA_DIR)
-include $(topsrcdir)/toolkit/mozapps/installer/package-name.mk
+include $(moztopsrcdir)/toolkit/mozapps/installer/package-name.mk
 
 BUILD_YEAR = $(shell echo $(BUILDID) | cut -c 1-4)
 BUILD_MONTH = $(shell echo $(BUILDID) | cut -c 5-6)
 BUILD_DAY = $(shell echo $(BUILDID) | cut -c 7-8)
 BUILD_HOUR = $(shell echo $(BUILDID) | cut -c 9-10)
 
 ifndef PKG_SUFFIX
 ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
@@ -66,17 +66,17 @@ FORCE_UPDATE := components/components.li
 
 #If there's a symbol server:
 # SYMBOL_SERVER_HOST=symbols.instantbird.org
 # SYMBOL_SERVER_PATH=/www/instantbird/socorro/symbols
 # SYMBOL_SERVER_PORT=22
 # SYMBOL_SERVER_USER=buildbot
 
 distribution:
-	@$(MAKE) MAKE_SYM_STORE_PATH=$(MAKE_SYM_STORE_PATH) SYM_STORE_SOURCE_DIRS='$(topsrcdir)/mozilla/extensions/purple $(topsrcdir)/mozilla $(topsrcdir)' buildsymbols
+	@$(MAKE) MAKE_SYM_STORE_PATH=$(MAKE_SYM_STORE_PATH) SYM_STORE_SOURCE_DIRS='$(moztopsrcdir)/extensions/purple $(moztopsrcdir) $(commtopsrcdir)' buildsymbols
 	@$(MAKE) -C im/installer libs installer
 ifdef ENABLE_TESTS
 	$(MAKE) xpcshell-tests
 endif
 	$(MAKE) -C tools/update-packaging complete-patch PKG_INST_PATH=
 ifdef L10NBASEDIR
 	$(foreach locale,$(SHIPPED_LOCALES),$(MAKE) -C im/locales/ repack-$(locale) LOCALE_MERGEDIR=mergedir MOZ_MAKE_COMPLETE_MAR=1 ;)
 endif
@@ -86,29 +86,29 @@ ifdef LIST_PREVIOUS_MAR_CMD
 	touch $(PATCH_FILE)
 	$(foreach marline,$(shell $(LIST_PREVIOUS_MAR_CMD)),\
 	  $(foreach MAR_FILE_SRC,$(shell echo $(marline) |cut -d : -f 3),\
 	    $(foreach AB_CD,$(filter $(shell echo $(marline) |cut -d : -f 2),$(AB_CD) $(SHIPPED_LOCALES)),\
 	      $(foreach buildid,$(shell echo $(marline) |cut -d : -f 1),\
 		mkdir -p $(PREVIOUS_MAR_DIR)/$(buildid) ; \
 	        $(DOWNLOAD_MAR_CMD) ; \
 		echo "$(MAR_FILE_DEST),$(DIST)/$(COMPLETE_MAR),$(DIST)/$(PKG_UPDATE_PATH)$(PKG_UPDATE_BASENAME).partial.from-$(buildid).mar,$(FORCE_UPDATE)" >> $(PATCH_FILE) ;))))
-	PATH="$(realpath $(DIST)/host/bin):$(PATH)" $(PYTHON) $(topsrcdir)/tools/update-packaging/make_incremental_updates.py -f $(PATCH_FILE)
+	PATH="$(realpath $(DIST)/host/bin):$(PATH)" $(PYTHON) $(moztopsrcdir)/tools/update-packaging/make_incremental_updates.py -f $(PATCH_FILE)
 endif
 ifdef SYMBOL_SERVER_HOST
 	@$(MAKE) uploadsymbols
 endif
 ifdef UPLOAD_CMD
 	$(MAKE) upload
 endif
 
 installer:
 	@$(MAKE) -C im/installer installer
 
-SHIPPED_LOCALES_FILE = $(topsrcdir)/im/locales/shipped-locales
+SHIPPED_LOCALES_FILE = $(commtopsrcdir)/im/locales/shipped-locales
 SHIPPED_LOCALES := $(shell if test -f $(SHIPPED_LOCALES_FILE); then cat $(SHIPPED_LOCALES_FILE); fi)
 
 package:
 	@$(MAKE) -C im/installer
 
 install::
 	@$(MAKE) -C im/installer install
 
--- a/im/configure.in
+++ b/im/configure.in
@@ -2,16 +2,41 @@ dnl -*- Mode: Autoconf; tab-width: 2; in
 dnl vi: set tabstop=2 shiftwidth=2 expandtab:
 dnl This Source Code Form is subject to the terms of the Mozilla Public
 dnl License, v. 2.0. If a copy of the MPL was not distributed with this
 dnl file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 dnl Things we need to carry from confvars.sh
 AC_SUBST(INSTANTBIRD_VERSION)
 
+dnl Set up variables based on if either the mozilla repo is the
+dnl subdirectory or the comm repo.
+if test "$MOZ_BUILD_APP" = "comm/im"
+then
+  dnl we are building with comm/ as the subdirectory
+  dnl $srcdir is the mozilla repo, comm is in the subdir
+  moztopsrcdir=$srcdir
+  commtopsrcdir=$srcdir/comm
+
+  mozreltopsrcdir=.
+  commreltopsrcdir=comm
+else
+  dnl we are building with mozilla/ as the subdirectory
+  dnl $srcdir is still the mozilla repo, so use the parent for comm
+  moztopsrcdir=$srcdir
+  commtopsrcdir=$srcdir/..
+
+  mozreltopsrcdir=mozilla
+  commreltopsrcdir=.
+fi
+AC_SUBST(moztopsrcdir)
+AC_SUBST(commtopsrcdir)
+AC_SUBST(mozreltopsrcdir)
+AC_SUBST(commreltopsrcdir)
+
 if test `echo "$MOZ_EXTENSIONS" | grep -c purple` -ne 0; then
     MOZ_PURPLE=1
     AC_SUBST(MOZ_PURPLE)
 fi
 
 if test -n "$MOZ_PURPLE"; then
   tmpscript=`$PYTHON -c 'import os, tempfile; print tempfile.mktemp(prefix="subscript.").replace(os.sep, "/")'` || exit 1
   m4 "${srcdir}/build/autoconf/subconfigure.m4" \
--- a/im/content/jar.mn
+++ b/im/content/jar.mn
@@ -1,12 +1,14 @@
 # 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/.
 
+#filter substitution
+
 instantbird.jar:
 % content instantbird %content/instantbird/
 #ifdef XP_MACOSX
 % overlay chrome://global/content/console.xul chrome://instantbird/content/jsConsoleOverlay.xul
 % overlay chrome://mozapps/content/update/updates.xul chrome://instantbird/content/softwareUpdateOverlay.xul
 #endif
 	content/instantbird/aboutDialog.css
 *	content/instantbird/aboutDialog.xul
@@ -92,17 +94,17 @@ instantbird.jar:
 	content/instantbird/preferences/themes.js               (preferences/themes.js)
 	content/instantbird/preferences/tabs.xul                (preferences/tabs.xul)
 	content/instantbird/preferences/tabs.js                 (preferences/tabs.js)
 	content/instantbird/preferences/messagestyle.js	        (preferences/messagestyle.js)
 	content/instantbird/preferences/smileys.js		(preferences/smileys.js)
 	content/instantbird/preferences/smiley.css		(preferences/smiley.css)
 	content/instantbird/preferences/smiley.xml		(preferences/smiley.xml)
 # override the toolkit license.html file
-* 	content/instantbird/license.html                        (/mozilla/toolkit/content/license.html)
+* 	content/instantbird/license.html                        (/@mozreltopsrcdir@/toolkit/content/license.html)
 % override chrome://global/content/license.html chrome://instantbird/content/license.html
 
 toolkit.jar:
 # toolkit dropped nsDragAndDrop.js in bug 1162050, ship a copy until we can remove it.
 	content/global/nsDragAndDrop.js 			(../../mail/base/content/nsDragAndDrop.js)
 
 #ifdef DEBUG
 debug.jar:
--- a/im/content/moz.build
+++ b/im/content/moz.build
@@ -1,18 +1,19 @@
 # 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/.
 
 JAR_MANIFESTS += ['jar.mn']
 
-# defines used for preference window files
-for var in ('MOZ_APP_NAME', 'MOZ_MACBUNDLE_NAME'):
+# defines used for preference window files and license
+for var in ('MOZ_APP_NAME', 'MOZ_MACBUNDLE_NAME', 'mozreltopsrcdir'):
     DEFINES[var] = CONFIG[var]
 
 #if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('windows', 'gtk2', 'gtk3', 'mac', 'cocoa'):
 #    DEFINES['HAVE_SHELL_SERVICE'] = 1
 
 if CONFIG['MOZ_UPDATER']:
     DEFINES['MOZ_UPDATER'] = 1
 
 DEFINES['APP_LICENSE_BLOCK'] = '%s/overrides/app-license.html' % SRCDIR
+
--- a/im/installer/Makefile.in
+++ b/im/installer/Makefile.in
@@ -1,27 +1,27 @@
 # 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/.
 
 STANDALONE_MAKEFILE := 1
 
-include $(topsrcdir)/config/rules.mk
+include $(moztopsrcdir)/config/rules.mk
 
 MOZ_PKG_REMOVALS = $(srcdir)/removed-files.in
 
 MOZ_PKG_MANIFEST_P = $(srcdir)/package-manifest.in
 # Some files have been already bundled with xulrunner
 ifndef SYSTEM_LIBXUL
 MOZ_PKG_FATAL_WARNINGS = 1
 endif
 MOZ_PKG_DUPEFLAGS = \
 	-f $(srcdir)/allowed-dupes.mn \
-	-f $(topsrcdir)/mail/installer/allowed-dupes.mn \
-	-f $(MOZILLA_DIR)/browser/installer/allowed-dupes.mn \
+	-f $(commtopsrcdir)/mail/installer/allowed-dupes.mn \
+	-f $(moztopsrcdir)/browser/installer/allowed-dupes.mn \
 	$(NULL)
 
 MOZ_NONLOCALIZED_PKG_LIST = \
 	xpcom \
 	im \
 	$(NULL)
 
 MOZ_LOCALIZED_PKG_LIST = $(AB_CD)
@@ -113,18 +113,18 @@ MOZ_PKG_MAC_BACKGROUND=branding/backgrou
 MOZ_PKG_MAC_ICON=branding/disk.icns
 MOZ_PKG_MAC_EXTRA=--symlink "/Applications:/ "
 endif
 
 NON_OMNIJAR_FILES =
 
 GENERATE_CACHE=1
 
-include $(MOZILLA_SRCDIR)/toolkit/mozapps/installer/signing.mk
-include $(MOZILLA_SRCDIR)/toolkit/mozapps/installer/packager.mk
+include $(moztopsrcdir)/toolkit/mozapps/installer/signing.mk
+include $(moztopsrcdir)/toolkit/mozapps/installer/packager.mk
 
 ifeq (bundle, $(MOZ_FS_LAYOUT))
 BINPATH = $(_BINPATH)
 DEFINES += -DAPPNAME=$(_APPNAME)
 else
 # Every other platform just winds up in dist/bin
 BINPATH = bin
 endif
@@ -184,12 +184,12 @@ ifdef MOZ_PKG_MANIFEST_P
 endif
 
 installer::
 ifdef INSTALLER_DIR
 	$(MAKE) -C $(INSTALLER_DIR)
 endif
 
 # The comm-* source stamp is already there.
-PLATFORM_SOURCE_STAMP = $(firstword $(shell hg -R "$(MOZILLA_SRCDIR)" parent --template="{node}\n" 2>/dev/null))
-PLATFORM_SOURCE_REPO = $(shell hg -R "$(MOZILLA_SRCDIR)" showconfig paths.default 2>/dev/null | sed -e "s/^ssh:/https:/")
+PLATFORM_SOURCE_STAMP = $(firstword $(shell hg -R "$(moztopsrcdir)" parent --template="{node}\n" 2>/dev/null))
+PLATFORM_SOURCE_REPO = $(shell hg -R "$(moztopsrcdir)" showconfig paths.default 2>/dev/null | sed -e "s/^ssh:/https:/")
 make-sourcestamp-file::
 	@echo "$(PLATFORM_SOURCE_REPO)/rev/$(PLATFORM_SOURCE_STAMP)" >> $(MOZ_SOURCESTAMP_FILE)
--- a/im/installer/windows/Makefile.in
+++ b/im/installer/windows/Makefile.in
@@ -1,19 +1,19 @@
 # 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/.
 
-include $(MOZILLA_SRCDIR)/toolkit/mozapps/installer/package-name.mk
+include $(moztopsrcdir)/toolkit/mozapps/installer/package-name.mk
 
 PKG_INST_PATH =
 CONFIG_DIR = instgen
-SFX_MODULE = $(topsrcdir)/other-licenses/7zstub/instantbird/7zSD.sfx
+SFX_MODULE = $(commtopsrcdir)/other-licenses/7zstub/instantbird/7zSD.sfx
 DEFINES += -DMOZ_APP_VERSION=$(MOZ_APP_VERSION)
-PRE_RELEASE_SUFFIX := $(shell $(PYTHON) $(topsrcdir)/mozilla/config/printprereleasesuffix.py $(MOZ_APP_VERSION))
+PRE_RELEASE_SUFFIX := $(shell $(PYTHON) $(moztopsrcdir)/config/printprereleasesuffix.py $(MOZ_APP_VERSION))
 DEFINES += -DPRE_RELEASE_SUFFIX="$(PRE_RELEASE_SUFFIX)"
 
 ifdef MOZ_UPDATER
 DEFINES += -DMOZ_UPDATER=1
 endif
 
 INSTALLER_FILES = \
 	app.tag \
@@ -30,39 +30,39 @@ BRANDING_FILES = \
 	$(NULL)
 
 DEFINES += \
 	-DMOZ_APP_NAME=$(MOZ_APP_NAME) \
 	-DMOZ_APP_DISPLAYNAME=${MOZ_APP_DISPLAYNAME} \
 	-DMOZILLA_VERSION=${MOZILLA_VERSION} \
 	$(NULL)
 
-include $(topsrcdir)/config/config.mk
+include $(moztopsrcdir)/config/config.mk
 
 OVERRIDE_DEFAULT_GOAL := installer
 installer::
 	$(MAKE) -C .. installer-stage
 	$(MAKE) $(CONFIG_DIR)/setup.exe
 
 # For building the uninstaller during the application build so it can be
 # included for mar file generation.
 uninstaller::
 	$(RM) -rf $(CONFIG_DIR) && mkdir $(CONFIG_DIR)
 	$(INSTALL) $(addprefix $(srcdir)/,$(INSTALLER_FILES)) $(CONFIG_DIR)
 	$(INSTALL) $(addprefix $(DIST)/branding/,$(BRANDING_FILES)) $(CONFIG_DIR)
 	$(call py_action,preprocessor,-Fsubstitution $(DEFINES) $(ACDEFINES) \
 	  $(srcdir)/nsis/defines.nsi.in -o $(CONFIG_DIR)/defines.nsi)
-	$(PYTHON) $(MOZILLA_SRCDIR)/toolkit/mozapps/installer/windows/nsis/preprocess-locale.py \
-          --preprocess-locale $(MOZILLA_SRCDIR) \
+	$(PYTHON) $(moztopsrcdir)/toolkit/mozapps/installer/windows/nsis/preprocess-locale.py \
+          --preprocess-locale $(moztopsrcdir) \
 	  $(call EXPAND_LOCALE_SRCDIR,im/locales)/installer $(AB_CD) $(CONFIG_DIR)
 
 $(CONFIG_DIR)/setup.exe::
 	$(RM) -rf $(CONFIG_DIR) && mkdir $(CONFIG_DIR)
 	$(INSTALL) $(addprefix $(srcdir)/,$(INSTALLER_FILES)) $(CONFIG_DIR)
 	$(INSTALL) $(addprefix $(DIST)/branding/,$(BRANDING_FILES)) $(CONFIG_DIR)
 	$(call py_action,preprocessor,-Fsubstitution $(DEFINES) $(ACDEFINES) \
 	  $(srcdir)/nsis/defines.nsi.in -o $(CONFIG_DIR)/defines.nsi)
-	$(PYTHON) $(MOZILLA_SRCDIR)/toolkit/mozapps/installer/windows/nsis/preprocess-locale.py \
-	  --preprocess-locale $(MOZILLA_SRCDIR) \
+	$(PYTHON) $(moztopsrcdir)/toolkit/mozapps/installer/windows/nsis/preprocess-locale.py \
+	  --preprocess-locale $(moztopsrcdir) \
 	  $(call EXPAND_LOCALE_SRCDIR,im/locales)/installer $(AB_CD) $(CONFIG_DIR)
 
-include $(topsrcdir)/config/rules.mk
-include $(MOZILLA_SRCDIR)/toolkit/mozapps/installer/windows/nsis/makensis.mk
+include $(moztopsrcdir)/config/rules.mk
+include $(moztopsrcdir)/toolkit/mozapps/installer/windows/nsis/makensis.mk
--- a/im/locales/Makefile.in
+++ b/im/locales/Makefile.in
@@ -1,15 +1,15 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-include $(topsrcdir)/config/config.mk
+include $(moztopsrcdir)/config/config.mk
 
-_ABS_SRCDIR := $(abspath $(topsrcdir))
+_ABS_SRCDIR := $(abspath $(commtopsrcdir))
 
 ifndef MOZ_BRANDING_DIRECTORY
 MOZ_BRANDING_DIRECTORY = im/branding/nightly
 endif
 
 SUBMAKEFILES += \
 	$(DEPTH)/$(MOZ_BRANDING_DIRECTORY)/Makefile \
 	$(DEPTH)/$(MOZ_BRANDING_DIRECTORY)/locales/Makefile \
@@ -35,18 +35,18 @@ PP_TARGETS += L10N_PREF_JS_EXPORTS
 
 ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
 MOZ_PKG_MAC_DSSTORE=$(ABS_DIST)/branding/dsstore
 MOZ_PKG_MAC_BACKGROUND=$(ABS_DIST)/branding/background.png
 MOZ_PKG_MAC_ICON=$(ABS_DIST)/branding/disk.icns
 MOZ_PKG_MAC_EXTRA=--symlink "/Applications:/ "
 endif
 
-MOZ_SFX_PACKAGE=$(topsrcdir)/other-licenses/7zstub/instantbird/7zSD.sfx
-MOZ_INSTALLER_PATH=$(topsrcdir)/im/installer/windows
+MOZ_SFX_PACKAGE=$(commtopsrcdir)/other-licenses/7zstub/instantbird/7zSD.sfx
+MOZ_INSTALLER_PATH=$(commtopsrcdir)/im/installer/windows
 
 ifeq (WINNT,$(OS_ARCH))
 UNINSTALLER_PACKAGE_HOOK = $(RM) -r $(STAGEDIST)/uninstall; \
     $(NSINSTALL) -D $(STAGEDIST)/uninstall; \
     cp ../installer/windows/l10ngen/helper.exe $(STAGEDIST)/uninstall; \
     $(RM) $(ABS_DIST)/l10n-stage/setup.exe; \
     cp ../installer/windows/l10ngen/setup.exe $(ABS_DIST)/l10n-stage; \
     $(NULL)
@@ -62,19 +62,19 @@ SEARCHPLUGINS := $(foreach plugin,$(adds
 SEARCHPLUGINS_FLAGS := --silence-missing-directive-warnings
 PP_TARGETS += SEARCHPLUGINS
 
 list-txt = $(SEARCHPLUGINS_PATH)/list.txt
 GARBAGE += $(list-txt)
 
 libs:: searchplugins
 
-include $(topsrcdir)/config/rules.mk
+include $(moztopsrcdir)/config/rules.mk
 
-include $(topsrcdir)/mozilla/toolkit/locales/l10n.mk
+include $(moztopsrcdir)/toolkit/locales/l10n.mk
 
 $(list-txt): $(call mkdir_deps,$(SEARCHPLUGINS_PATH)) $(if $(IS_LANGUAGE_REPACK),FORCE)
 	$(RM) $(list-txt)
 	$(foreach plugin,$(SEARCHPLUGINS_NAMES),printf '$(plugin)\n' >> $(list-txt);)
 searchplugins:: $(list-txt)
 
 # Remove installer/sea/ from installer paths.
 PKG_INST_PATH =
@@ -146,23 +146,23 @@ else
 	  sed -e "s/^InfoText=/Info=/" -e "s/^TitleText=/Title=/" | \
 	  sed -e "s/%MOZ_APP_DISPLAYNAME%/$(MOZ_APP_DISPLAYNAME)/" > \
 	  $(FINAL_TARGET)/updater.ini
 endif
 endif
 
 ident:
 	@printf "ib_revision "
-	@$(PYTHON) $(MOZILLA_SRCDIR)/config/printconfigsetting.py \
+	@$(PYTHON) $(moztopsrcdir)/config/printconfigsetting.py \
 	    $(STAGEDIST)/application.ini App SourceStamp
 	@printf "moz_revision "
-	@$(PYTHON) $(MOZILLA_SRCDIR)/config/printconfigsetting.py \
+	@$(PYTHON) $(moztopsrcdir)/config/printconfigsetting.py \
 	    $(STAGEDIST)/platform.ini Build SourceStamp
 	@printf "buildid "
-	@$(PYTHON) $(MOZILLA_SRCDIR)/config/printconfigsetting.py \
+	@$(PYTHON) $(moztopsrcdir)/config/printconfigsetting.py \
 	    $(STAGEDIST)/application.ini App BuildID
 
 #These make targets call prepare-repackages by setting different UPLOAD_DIR
 prepare-upload-latest-%:
 	@$(MAKE) prepare-repackages-$* UPLOAD_DIR=$(DIST)/upload/latest
 
 prepare-upload-dated-%:
 	@$(MAKE) prepare-repackages-$* UPLOAD_DIR=$(DIST)/upload/`date "+%Y-%m-%d-%H"`-$(MOZ_PKG_APPNAME)$(MOZ_APP_VERSION)-l10n
@@ -201,16 +201,16 @@ ifdef LOCALE_MERGEDIR
 endif
 	@echo
 
 IB_L10N_REPO_BASE = https://hg.instantbird.org/l10n
 MOZ_L10N_REPO_BASE = https://hg.mozilla.org/releases/l10n-mozilla-2.0
 
 checkout-%: AB_CD=$*
 checkout-%:
-	mkdir -p $(topsrcdir)/$(L10NBASEDIR)
-	$(PYTHON) $(topsrcdir)/client.py checkout-l10n --skip-instantbird --clean --l10n-base-dir $(L10NBASEDIR) --locale $(AB_CD)
+	mkdir -p $(commtopsrcdir)/$(L10NBASEDIR)
+	$(PYTHON) $(commtopsrcdir)/client.py checkout-l10n --skip-instantbird --clean --l10n-base-dir $(L10NBASEDIR) --locale $(AB_CD)
 
 repack-%: AB_CD=$*
 repack-%:
 	make checkout-$(AB_CD)
 	make merge-$(AB_CD)
 	make installers-$(AB_CD)
--- a/ldap/c-sdk/libraries/liblber/moz.build
+++ b/ldap/c-sdk/libraries/liblber/moz.build
@@ -1,23 +1,23 @@
 # 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/.
 
-include('/ldap/ldap-sdk.mozbuild')
+include('/%s/ldap/ldap-sdk.mozbuild' % CONFIG['commreltopsrcdir'])
 
 Library('lber60')
 
 SOURCES += [
     'bprint.c',
     'decode.c',
     'encode.c',
     'io.c',
 ]
 
 DEFINES['USE_WAITPID'] = True
 DEFINES['NEEDPROTOS'] = True
 
 LOCAL_INCLUDES += [
-    '/ldap/c-sdk/include'
+    '../../include'
 ]
 
--- a/ldap/c-sdk/libraries/libldap/moz.build
+++ b/ldap/c-sdk/libraries/libldap/moz.build
@@ -1,14 +1,14 @@
 # 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/.
 
-include('/ldap/ldap-sdk.mozbuild')
+include('/%s/ldap/ldap-sdk.mozbuild' % CONFIG['commreltopsrcdir'])
 
 SharedLibrary('ldap60')
 
 SOURCES += [
     'abandon.c',
     'add.c',
     'authzidctrl.c',
     'bind.c',
@@ -77,12 +77,12 @@ if CONFIG['OS_TARGET'] == 'WINNT':
 
 if CONFIG['OS_TARGET'] != 'WINNT':
     DEFINES['USE_WAITPID'] = True
     DEFINES['USE_PTHREADS'] = True
 
 DEFINES['NEEDPROTOS'] = True
 
 LOCAL_INCLUDES += [
-    '/ldap/c-sdk/include'
+    '../../include'
 ]
 
 USE_LIBS += ['lber60']
--- a/ldap/c-sdk/libraries/libldif/moz.build
+++ b/ldap/c-sdk/libraries/libldif/moz.build
@@ -1,23 +1,22 @@
 # 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/.
 
-include('/ldap/ldap-sdk.mozbuild')
+include('/%s/ldap/ldap-sdk.mozbuild' % CONFIG['commreltopsrcdir'])
 
 SharedLibrary('ldif60')
 
 SOURCES += [
     'line64.c'
 ]
 
 LOCAL_INCLUDES += [
-    '/ldap/c-sdk/include'
+    '../../include'
 ]
 
 if CONFIG['OS_ARCH'] == 'WINNT':
     DEFFILE = SRCDIR + '/libldif.def'
 
 DEFINES['USE_WAITPID'] = True
 DEFINES['NEEDPROTOS'] = True
-
--- a/ldap/c-sdk/libraries/libprldap/moz.build
+++ b/ldap/c-sdk/libraries/libprldap/moz.build
@@ -1,14 +1,14 @@
 # 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/.
 
-include('/ldap/ldap-sdk.mozbuild')
+include('/%s/ldap/ldap-sdk.mozbuild' % CONFIG['commreltopsrcdir'])
 
 SharedLibrary('prldap60')
 
 SOURCES += [
     'ldappr-dns.c',
     'ldappr-error.c',
     'ldappr-io.c',
     'ldappr-public.c',
@@ -17,15 +17,15 @@ SOURCES += [
 
 if CONFIG['OS_ARCH'] == 'WINNT':
     DEFFILE = SRCDIR + '/libprldap.def'
 
 DEFINES['USE_WAITPID'] = True
 DEFINES['NEEDPROTOS'] = True
 
 LOCAL_INCLUDES += [
-    '/ldap/c-sdk/include'
+    '../../include'
 ]
 
 USE_LIBS += [
     'ldap60',
     'nspr'
 ]
--- a/ldap/xpcom/src/moz.build
+++ b/ldap/xpcom/src/moz.build
@@ -30,11 +30,11 @@ EXTRA_COMPONENTS += [
 USE_LIBS += [
     'ldapsdks',
 ]
 
 Library('mozldap')
 FINAL_LIBRARY = 'xul'
 
 LOCAL_INCLUDES += [
-    '/ldap/c-sdk/include',
+    '../../c-sdk/include',
 ]
 
--- a/mail/Makefile.in
+++ b/mail/Makefile.in
@@ -1,41 +1,40 @@
-#
 # 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/.
 
-include $(topsrcdir)/config/config.mk
+include $(moztopsrcdir)/config/config.mk
 
 ifdef ENABLE_TESTS
 
 check-sync-dirs::
-	@$(PYTHON) $(topsrcdir)/mail/check-sync-dirs.py \
-	   $(topsrcdir)/build $(MOZILLA_SRCDIR)/build
-	@$(PYTHON) $(topsrcdir)/mail/check-sync-dirs.py \
-	   $(srcdir)/config/tooltool-manifests $(MOZILLA_SRCDIR)/browser/config/tooltool-manifests
+	@$(PYTHON) $(commtopsrcdir)/mail/check-sync-dirs.py \
+	   $(topsrcdir)/build $(moztopsrcdir)/build
+	@$(PYTHON) $(commtopsrcdir)/mail/check-sync-dirs.py \
+	   $(srcdir)/config/tooltool-manifests $(moztopsrcdir)/browser/config/tooltool-manifests
 
 check:: check-sync-dirs
 endif
 
-include $(topsrcdir)/config/rules.mk
+include $(moztopsrcdir)/config/rules.mk
 
 ifdef MAKENSISU
 # For Windows build the uninstaller during the application build since the
 # uninstaller is included with the application for mar file generation.
 libs::
 	$(MAKE) -C installer/windows uninstaller
 ifdef MOZ_MAINTENANCE_SERVICE
 	$(MAKE) -C installer/windows maintenanceservice_installer
 endif
 endif
 
 
 # As a fallout from bug 1247162, the sourcestamp in application.ini and
 # platform.ini are the same, which isn't a problem for Firefox, but
 # it's not right for anything else. So we correct platform.ini here.
 
-MOZ_REV=$(shell hg -R "$(MOZILLA_SRCDIR)" parent --template="{node}" 2>/dev/null)
+MOZ_REV=$(shell hg -R "$(moztopsrcdir)" parent --template="{node}" 2>/dev/null)
 
 libs:: $(DIST)/bin/platform.ini
 	sed -e "s/^\(SourceStamp=\).*/\1$(MOZ_REV)/" $(DIST)/bin/platform.ini \
 		> $(DIST)/bin/platform.ini~
 	mv -f $(DIST)/bin/platform.ini~ $(DIST)/bin/platform.ini
--- a/mail/app.mozbuild
+++ b/mail/app.mozbuild
@@ -1,29 +1,29 @@
 # 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/.
 
-include('/mailnews/mailnews.mozbuild')
+include('../mailnews/mailnews.mozbuild')
 
-DIRS += ['/mail/components']
+DIRS += ['/%s/mail/components' % CONFIG['commreltopsrcdir']]
 
-include('/toolkit/toolkit.mozbuild')
+include('/%s/toolkit/toolkit.mozbuild' % CONFIG['mozreltopsrcdir'])
 
 if CONFIG['MOZ_EXTENSIONS']:
-    DIRS += ['/extensions']
+    DIRS += ['/%s/extensions' % CONFIG['mozreltopsrcdir']]
 
 DIRS += ['/%s' % CONFIG['MOZ_BRANDING_DIRECTORY']]
 
 if CONFIG['MOZ_COMPOSER']:
-    DIRS += ['/editor/ui']
+    DIRS += ['/%s/editor/ui' % CONFIG['commreltopsrcdir']]
 
 if CONFIG['MOZ_CALENDAR']:
     DIRS += [
-        '/calendar/lightning',
-        '/calendar/timezones'
+        '/%s/calendar/lightning' % CONFIG['commreltopsrcdir'],
+        '/%s/calendar/timezones' % CONFIG['commreltopsrcdir']
     ]
 
 DIRS += [
-    '/chat',
-    '/mail',
+    '/%s/chat' % CONFIG['commreltopsrcdir'],
+    '/%s/mail' % CONFIG['commreltopsrcdir'],
 ]
--- a/mail/app/Makefile.in
+++ b/mail/app/Makefile.in
@@ -1,16 +1,16 @@
 # 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/.
 
 AB_CD = $(MOZ_UI_LOCALE)
 
-GRE_MILESTONE = $(shell $(PYTHON) $(MOZILLA_SRCDIR)/config/printconfigsetting.py $(DIST)/bin/platform.ini Build Milestone)
-MOZ_BUILDID = $(shell $(PYTHON) $(MOZILLA_SRCDIR)/config/printconfigsetting.py $(DIST)/bin/platform.ini Build BuildID)
+GRE_MILESTONE = $(shell $(PYTHON) $(moztopsrcdir)/config/printconfigsetting.py $(DIST)/bin/platform.ini Build Milestone)
+MOZ_BUILDID = $(shell $(PYTHON) $(moztopsrcdir)/config/printconfigsetting.py $(DIST)/bin/platform.ini Build BuildID)
 
 DEFINES += \
   -DTHUNDERBIRD_ICO='"$(DIST)/branding/thunderbird.ico"' \
    $(NULL)
 
 # Build a binary bootstrapping with XRE_main
 
 ifndef MOZ_WINCONSOLE
@@ -20,30 +20,30 @@ else
 MOZ_WINCONSOLE = 0
 endif
 endif
 
 # This switches $(INSTALL) to copy mode, like $(SYSINSTALL), so things that
 # shouldn't get 755 perms need $(IFLAGS1) for either way of calling nsinstall.
 NSDISTMODE = copy
 
-include $(topsrcdir)/config/config.mk
+include $(moztopsrcdir)/config/config.mk
 
 # If we are trying to show an error dialog about the lack of SSE2 support,
 # make sure that code itself doesn't use SSE2.
 ifdef MOZ_LINUX_32_SSE2_STARTUP_ERROR
 CXXFLAGS := $(filter-out -march=% -msse -msse2 -mfpmath=sse,$(CXXFLAGS))
 CXX := $(filter-out -march=% -msse -msse2 -mfpmath=sse,$(CXX))
 CXXFLAGS += -mno-sse -mno-sse2 -mfpmath=387
 CXX += -march=pentiumpro
 endif
 
 ifeq ($(OS_ARCH),WINNT)
 # Extract the icons we care about embedding into the EXE
-mailtoolbar = $(topsrcdir)/mail/themes/windows/mail/icons/jumplist.png
+mailtoolbar = $(commtopsrcdir)/mail/themes/windows/mail/icons/jumplist.png
 
 # png to ico converter. The function takes 5 arguments, in order: source png
 # file, left, top, size, output ico file.
 png2ico = $(PYTHON) $(srcdir)/png2ico.py $(1) $(2) $(3) $(4) $(5)
 
 # Each icon is 18x18 in the toolbar, and we want a 16x16 icon here, so we cut
 # off a pixel at each end.
 write-message.ico: $(mailtoolbar) $(srcdir)/png2ico.py
@@ -57,17 +57,17 @@ GARBAGE += write-message.ico address-boo
 
 # Rebuild thunderbird.exe if the manifest changes - it's included by splash.rc.
 # (this dependency should really be just for thunderbird.exe, not other targets)
 # Note the manifest file exists in the tree, so we use the explicit filename
 # here.
 EXTRA_DEPS += thunderbird.exe.manifest
 endif
 
-include $(topsrcdir)/config/rules.mk
+include $(moztopsrcdir)/config/rules.mk
 
 ifeq ($(OS_ARCH),WINNT)
 
 $(RESFILE): embedded-icons
 
 endif
 
 ifneq ($(OS_ARCH),WINNT)
--- a/mail/app/moz.build
+++ b/mail/app/moz.build
@@ -5,36 +5,36 @@
 
 DIRS += ['profile']
 
 GeckoProgram(CONFIG['MOZ_APP_NAME'])
 USE_LIBS += ['mozglue']
 SOURCES += ['nsMailApp.cpp']
 LOCAL_INCLUDES += [
     '!/build',
-    '/mozilla/toolkit/xre',
-    '/mozilla/xpcom/base',
-    '/mozilla/xpcom/build',
+    '/%s/toolkit/xre' % CONFIG['mozreltopsrcdir'],
+    '/%s/xpcom/base' % CONFIG['mozreltopsrcdir'],
+    '/%s/xpcom/build' % CONFIG['mozreltopsrcdir'],
 ]
 
 if CONFIG['LIBFUZZER']:
     USE_LIBS += [ 'fuzzer' ]
     LOCAL_INCLUDES += [
-        '/mozilla/tools/fuzzing/libfuzzer',
+        '/%s/tools/fuzzing/libfuzzer' % CONFIG['mozreltopsrcdir'],
     ]
 
 if CONFIG['OS_ARCH'] == 'WINNT':
     RCINCLUDE = 'splash.rc'
     DEFINES['MOZ_THUNDERBIRD'] = True
 
 if CONFIG['MOZ_SANDBOX'] and CONFIG['OS_ARCH'] == 'WINNT':
     # For sandbox includes and the include dependencies those have
     LOCAL_INCLUDES += [
-        '/mozilla/security/sandbox/chromium',
-        '/mozilla/security/sandbox/chromium-shim',
+        '/%s/security/sandbox/chromium' % CONFIG['mozreltopsrcdir'],
+        '/%s/security/sandbox/chromium-shim' % CONFIG['mozreltopsrcdir'],
     ]
 
     USE_LIBS += [
         'sandbox_s',
     ]
 
     DELAYLOAD_DLLS += [
         'winmm.dll',
--- a/mail/app/profile/extensions/Makefile.in
+++ b/mail/app/profile/extensions/Makefile.in
@@ -1,16 +1,16 @@
 #
 # 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/.
 
 DISTROEXT = $(ABS_DIST)/bin/distribution/extensions
 
-include $(topsrcdir)/config/rules.mk
+include $(moztopsrcdir)/config/rules.mk
 
 # If adding extra extensions here, check that EXTRA_ARGS defined below won't
 # affect them unintentionally.
 EXTENSIONS = \
   $(NULL)
 
 # We are in release mode, we don't want to ship the debug file.
 ifndef MOZ_DEBUG
--- a/mail/base/jar.mn
+++ b/mail/base/jar.mn
@@ -1,8 +1,10 @@
+#filter substitution
+
 messenger.jar:
 % content messagebody %content/messagebody/ contentaccessible=yes
 % content messenger %content/messenger/
 % override chrome://global/content/nsDragAndDrop.js chrome://messenger/content/nsDragAndDrop.js
 % override chrome://messagebody/skin/messageBody.css chrome://messenger/skin/messageBody.css
 % overlay chrome://global/content/viewSource.xul chrome://messenger/content/viewSourceOverlay.xul
 % overlay chrome://global/content/config.xul chrome://messenger/content/configEditorOverlay.xul
 % overlay chrome://editor/content/EdSpellCheck.xul chrome://messenger/content/EdSpellCheckOverlay.xul
@@ -110,22 +112,22 @@ messenger.jar:
 *   content/messenger/safeMode.xul                  (content/safeMode.xul)
     content/messenger/safeMode.js                   (content/safeMode.js)
     content/messenger/sanitize.xul                  (content/sanitize.xul)
     content/messenger/sanitize.js                   (content/sanitize.js)
     content/messenger/sanitizeDialog.css            (content/sanitizeDialog.css)
     content/messenger/sanitizeDialog.js             (content/sanitizeDialog.js)
 *   content/messenger/toolbarIconColor.js           (content/toolbarIconColor.js)
 # the following files are mail-specific overrides
-*   content/messenger/license.html                  (/mozilla/toolkit/content/license.html)
+*   content/messenger/license.html                  (/@mozreltopsrcdir@/toolkit/content/license.html)
 % override chrome://global/content/license.html chrome://messenger/content/license.html
 
 comm.jar:
 % content communicator %content/communicator/
    content/communicator/charsetOverlay.xul          (content/charsetOverlay.xul)
    content/communicator/contentAreaClick.js         (content/contentAreaClick.js)
-   content/communicator/labelsencodings.properties  (/mozilla/dom/encoding/labelsencodings.properties)
+   content/communicator/labelsencodings.properties  (/@mozreltopsrcdir@/dom/encoding/labelsencodings.properties)
 *  content/communicator/utilityOverlay.xul          (content/utilityOverlay.xul)
    content/communicator/utilityOverlay.js           (content/utilityOverlay.js)
 
 toolkit.jar:
 % overlay chrome://global/content/customizeToolbar.xul chrome://messenger/content/customizeToolbarOverlay.xul
 % overlay chrome://mozapps/content/downloads/downloads.xul chrome://messenger/content/downloadsOverlay.xul
--- a/mail/base/moz.build
+++ b/mail/base/moz.build
@@ -7,16 +7,17 @@ DIRS += ['modules']
 
 TEST_DIRS += ['test']
 
 JAR_MANIFESTS += ['jar.mn']
 
 DEFINES['PRE_RELEASE_SUFFIX'] = ''
 DEFINES['MOZ_APP_VERSION'] = CONFIG['MOZ_APP_VERSION']
 DEFINES['MOZ_APP_VERSION_DISPLAY'] = CONFIG['MOZ_APP_VERSION_DISPLAY']
+DEFINES['mozreltopsrcdir'] = CONFIG['mozreltopsrcdir']
 DEFINES['APP_LICENSE_BLOCK'] = '%s/content/overrides/app-license.html' % SRCDIR
 
 if CONFIG['MOZILLA_OFFICIAL']:
     DEFINES['OFFICIAL_BUILD'] = 1
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('windows', 'gtk2', 'gtk3', 'cocoa'):
     DEFINES['HAVE_SHELL_SERVICE'] = 1
 
--- a/mail/branding/aurora/Makefile.in
+++ b/mail/branding/aurora/Makefile.in
@@ -1,15 +1,15 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 # Branding Makefile for nightlies/unofficial branding
 
-include $(topsrcdir)/config/rules.mk
+include $(moztopsrcdir)/config/rules.mk
 
 export::
 	$(NSINSTALL) -D $(DIST)/branding
 ifeq ($(OS_ARCH),WINNT)
 	cp $(srcdir)/thunderbird.ico   $(DIST)/branding/thunderbird.ico
 	cp $(srcdir)/branding.nsi      $(DIST)/branding/branding.nsi
 	cp $(srcdir)/wizHeader.bmp     $(DIST)/branding/wizHeader.bmp
 	cp $(srcdir)/wizHeaderRTL.bmp  $(DIST)/branding/wizHeaderRTL.bmp
--- a/mail/branding/nightly/Makefile.in
+++ b/mail/branding/nightly/Makefile.in
@@ -1,15 +1,15 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 # Branding Makefile for nightlies/unofficial branding
 
-include $(topsrcdir)/config/rules.mk
+include $(moztopsrcdir)/config/rules.mk
 
 export::
 	$(NSINSTALL) -D $(DIST)/branding
 ifeq ($(OS_ARCH),WINNT)
 	cp $(srcdir)/thunderbird.ico   $(DIST)/branding/thunderbird.ico
 	cp $(srcdir)/branding.nsi      $(DIST)/branding/branding.nsi
 	cp $(srcdir)/wizHeader.bmp     $(DIST)/branding/wizHeader.bmp
 	cp $(srcdir)/wizHeaderRTL.bmp  $(DIST)/branding/wizHeaderRTL.bmp
--- a/mail/build.mk
+++ b/mail/build.mk
@@ -1,43 +1,43 @@
 # 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 COMM_BUILD
 installer:
-	@$(MAKE) -C mail/installer installer
+	@$(MAKE) -C $(MOZ_BUILD_APP)/installer installer
 
 package:
-	@$(MAKE) -C mail/installer
+	$(MAKE) -C $(MOZ_BUILD_APP)/installer
 
 package-compare:
-	@$(MAKE) -C mail/installer package-compare
+	@$(MAKE) -C $(MOZ_BUILD_APP)/installer package-compare
 
 stage-package:
-	@$(MAKE) -C mail/installer stage-package
+	@$(MAKE) -C $(MOZ_BUILD_APP)/installer stage-package
 
 install::
-	@$(MAKE) -C mail/installer install
+	@$(MAKE) -C $(MOZ_BUILD_APP)/installer install
 
 source-package::
-	@$(MAKE) -C mail/installer source-package
+	@$(MAKE) -C $(MOZ_BUILD_APP)/installer source-package
 
 upload::
-	@$(MAKE) -C mail/installer upload
+	@$(MAKE) -C $(MOZ_BUILD_APP)/installer upload
 ifdef MOZ_CALENDAR
-	@$(MAKE) -C calendar/lightning upload
-	@$(MAKE) -C calendar/providers/gdata upload
+	@$(MAKE) -C $(commtopsrcdir)/calendar/lightning upload
+	@$(MAKE) -C $(commtopsrcdir)/calendar/providers/gdata upload
 endif
 
 source-upload::
-	@$(MAKE) -C mail/installer source-upload
+	@$(MAKE) -C $(MOZ_BUILD_APP)/installer source-upload
 
 hg-bundle::
-	@$(MAKE) -C mail/installer hg-bundle
+	@$(MAKE) -C $(MOZ_BUILD_APP)/installer hg-bundle
 
 l10n-check::
-	@$(MAKE) -C mail/locales l10n-check
+	@$(MAKE) -C $(MOZ_BUILD_APP)/locales l10n-check
 
 ifdef ENABLE_TESTS
-include $(topsrcdir)/../mail/testsuite-targets.mk
+include $(commtopsrcdir)/mail/testsuite-targets.mk
 endif
 endif
--- a/mail/components/search/mdimporter/Makefile.in
+++ b/mail/components/search/mdimporter/Makefile.in
@@ -17,13 +17,13 @@ INSTALL_TARGETS += SCHEMA
 PLIST_FILES := Info.plist
 PLIST_DEST := $(FRAMEWORK_DIR)/Contents
 INSTALL_TARGETS += PLIST
 
 CFLAGS += -mmacosx-version-min=$(MACOSX_DEPLOYMENT_TARGET)
 # We don't need mozglue
 WRAP_LDFLAGS :=
 
-include $(topsrcdir)/config/rules.mk
+include $(moztopsrcdir)/config/rules.mk
 
 # We're also a bundle.
 LDFLAGS += -bundle
 
--- a/mail/configure.in
+++ b/mail/configure.in
@@ -7,16 +7,41 @@ dnl file, You can obtain one at http://m
 dnl Things we need to carry from confvars.sh
 AC_DEFINE(MOZ_THUNDERBIRD)
 AC_SUBST(MOZ_THUNDERBIRD)
 AC_SUBST(MOZ_COMPOSER)
 AC_SUBST(THUNDERBIRD_VERSION)
 AC_DEFINE(MOZ_SEPARATE_MANIFEST_FOR_THEME_OVERRIDES)
 AC_SUBST(MOZ_BUNDLED_FONTS)
 
+dnl Set up variables based on if either the mozilla repo is the
+dnl subdirectory or the comm repo.
+if test "$MOZ_BUILD_APP" = "comm/mail"
+then
+  dnl we are building with comm/ as the subdirectory
+  dnl $srcdir is the mozilla repo, comm is in the subdir
+  moztopsrcdir=$srcdir
+  commtopsrcdir=$srcdir/comm
+
+  mozreltopsrcdir=.
+  commreltopsrcdir=comm
+else
+  dnl we are building with mozilla/ as the subdirectory
+  dnl $srcdir is still the mozilla repo, so use the parent for comm
+  moztopsrcdir=$srcdir
+  commtopsrcdir=$srcdir/..
+
+  mozreltopsrcdir=mozilla
+  commreltopsrcdir=.
+fi
+AC_SUBST(moztopsrcdir)
+AC_SUBST(commtopsrcdir)
+AC_SUBST(mozreltopsrcdir)
+AC_SUBST(commreltopsrcdir)
+
 dnl Optional parts of the build.
 AC_SUBST(MOZ_MORK)
 if test "$MOZ_MORK"; then
   AC_DEFINE(MOZ_MORK)
 fi
 if test "$OS_ARCH" != "WINNT"; then
   MOZ_MOVEMAIL=1
   HAVE_MOVEMAIL=1
--- a/mail/confvars.sh
+++ b/mail/confvars.sh
@@ -25,18 +25,18 @@ fi
 MOZ_MORK=1
 
 MOZ_APP_VERSION_TXT=${_topsrcdir}/$MOZ_BUILD_APP/config/version.txt
 MOZ_APP_VERSION=`cat $MOZ_APP_VERSION_TXT`
 MOZ_APP_VERSION_DISPLAY_TXT=${_topsrcdir}/$MOZ_BUILD_APP/config/version_display.txt
 MOZ_APP_VERSION_DISPLAY=`cat $MOZ_APP_VERSION_DISPLAY_TXT`
 THUNDERBIRD_VERSION=$MOZ_APP_VERSION
 
-MOZ_BRANDING_DIRECTORY=mail/branding/nightly
-MOZ_OFFICIAL_BRANDING_DIRECTORY=other-licenses/branding/thunderbird
+MOZ_BRANDING_DIRECTORY=$MOZ_BUILD_APP/branding/nightly
+MOZ_OFFICIAL_BRANDING_DIRECTORY=$MOZ_BUILD_APP/../other-licenses/branding/thunderbird
 MOZ_APP_ID={3550f703-e582-4d05-9a08-453d09bdfdc6}
 # This should usually be the same as the value MAR_CHANNEL_ID.
 # If more than one ID is needed, then you should use a comma separated list
 # of values.
 ACCEPTED_MAR_CHANNEL_IDS=thunderbird-comm-central
 # The MAR_CHANNEL_ID must not contain the following 3 characters: ",\t "
 MAR_CHANNEL_ID=thunderbird-comm-central
 MOZ_PROFILE_MIGRATOR=1
--- a/mail/extensions/smime/jar.mn
+++ b/mail/extensions/smime/jar.mn
@@ -9,21 +9,21 @@ messenger.jar:
 % overlay chrome://messenger/content/messenger.xul chrome://messenger-smime/content/msgReadSMIMEOverlay.xul
 % overlay chrome://messenger/content/messageWindow.xul chrome://messenger-smime/content/msgReadSMIMEOverlay.xul
 % overlay chrome://messenger/content/am-identity-edit.xul chrome://messenger/content/am-smimeIdentityEditOverlay.xul
    content/messenger-smime/msgReadSMIMEOverlay.xul                  (content/msgReadSMIMEOverlay.xul)
    content/messenger-smime/msgCompSMIMEOverlay.xul                  (content/msgCompSMIMEOverlay.xul)
    content/messenger-smime/msgCompSMIMEOverlay.js                   (content/msgCompSMIMEOverlay.js)
    content/messenger-smime/msgHdrViewSMIMEOverlay.js                (content/msgHdrViewSMIMEOverlay.js)
    content/messenger-smime/msgHdrViewSMIMEOverlay.xul               (content/msgHdrViewSMIMEOverlay.xul)
-   content/messenger/am-smime.xul                                   (/mailnews/extensions/smime/content/am-smime.xul)
-   content/messenger/am-smime.js                                    (/mailnews/extensions/smime/content/am-smime.js)
-   content/messenger/am-smimeIdentityEditOverlay.xul                (/mailnews/extensions/smime/content/am-smimeIdentityEditOverlay.xul)
-   content/messenger/am-smimeOverlay.xul                            (/mailnews/extensions/smime/content/am-smimeOverlay.xul)
-   content/messenger/certpicker.js                                  (/mailnews/extensions/smime/content/certpicker.js)
-   content/messenger/certpicker.xul                                 (/mailnews/extensions/smime/content/certpicker.xul)
-   content/messenger-smime/msgReadSMIMEOverlay.js                   (/mailnews/extensions/smime/content/msgReadSMIMEOverlay.js)
-   content/messenger-smime/msgCompSecurityInfo.js                   (/mailnews/extensions/smime/content/msgCompSecurityInfo.js)
-   content/messenger-smime/msgCompSecurityInfo.xul                  (/mailnews/extensions/smime/content/msgCompSecurityInfo.xul)
-   content/messenger-smime/msgReadSecurityInfo.xul                  (/mailnews/extensions/smime/content/msgReadSecurityInfo.xul)
-   content/messenger-smime/msgReadSecurityInfo.js                   (/mailnews/extensions/smime/content/msgReadSecurityInfo.js)
-   content/messenger-smime/certFetchingStatus.xul                   (/mailnews/extensions/smime/content/certFetchingStatus.xul)
-   content/messenger-smime/certFetchingStatus.js                    (/mailnews/extensions/smime/content/certFetchingStatus.js)
+   content/messenger/am-smime.xul                                   (../../../mailnews/extensions/smime/content/am-smime.xul)
+   content/messenger/am-smime.js                                    (../../../mailnews/extensions/smime/content/am-smime.js)
+   content/messenger/am-smimeIdentityEditOverlay.xul                (../../../mailnews/extensions/smime/content/am-smimeIdentityEditOverlay.xul)
+   content/messenger/am-smimeOverlay.xul                            (../../../mailnews/extensions/smime/content/am-smimeOverlay.xul)
+   content/messenger/certpicker.js                                  (../../../mailnews/extensions/smime/content/certpicker.js)
+   content/messenger/certpicker.xul                                 (../../../mailnews/extensions/smime/content/certpicker.xul)
+   content/messenger-smime/msgReadSMIMEOverlay.js                   (../../../mailnews/extensions/smime/content/msgReadSMIMEOverlay.js)
+   content/messenger-smime/msgCompSecurityInfo.js                   (../../../mailnews/extensions/smime/content/msgCompSecurityInfo.js)
+   content/messenger-smime/msgCompSecurityInfo.xul                  (../../../mailnews/extensions/smime/content/msgCompSecurityInfo.xul)
+   content/messenger-smime/msgReadSecurityInfo.xul                  (../../../mailnews/extensions/smime/content/msgReadSecurityInfo.xul)
+   content/messenger-smime/msgReadSecurityInfo.js                   (../../../mailnews/extensions/smime/content/msgReadSecurityInfo.js)
+   content/messenger-smime/certFetchingStatus.xul                   (../../../mailnews/extensions/smime/content/certFetchingStatus.xul)
+   content/messenger-smime/certFetchingStatus.js                    (../../../mailnews/extensions/smime/content/certFetchingStatus.js)
--- a/mail/installer/Makefile.in
+++ b/mail/installer/Makefile.in
@@ -1,16 +1,16 @@
 # 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/.
 
 STANDALONE_MAKEFILE := 1
 # DIST_SUBDIR := mail  # Not sure why TB is not using this
 
-include $(topsrcdir)/config/rules.mk
+include $(moztopsrcdir)/config/rules.mk
 
 MOZ_PKG_REMOVALS = $(srcdir)/removed-files.in
 
 MOZ_PKG_MANIFEST_P = $(srcdir)/package-manifest.in
 # Some files have been already bundled with xulrunner
 ifndef SYSTEM_LIBXUL
 MOZ_PKG_FATAL_WARNINGS = 1
 endif
@@ -127,18 +127,18 @@ ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
 MOZ_PKG_MAC_DSSTORE=branding/dsstore
 MOZ_PKG_MAC_BACKGROUND=branding/background.png
 MOZ_PKG_MAC_ICON=branding/disk.icns
 MOZ_PKG_MAC_EXTRA=--symlink '/Applications:/ '
 endif
 
 NON_OMNIJAR_FILES = defaults/messenger/mailViews.dat
 
-include $(MOZILLA_SRCDIR)/toolkit/mozapps/installer/signing.mk
-include $(MOZILLA_SRCDIR)/toolkit/mozapps/installer/packager.mk
+include $(moztopsrcdir)/toolkit/mozapps/installer/signing.mk
+include $(moztopsrcdir)/toolkit/mozapps/installer/packager.mk
 
 ifeq (bundle, $(MOZ_FS_LAYOUT))
 BINPATH = $(_BINPATH)
 DEFINES += -DAPPNAME=$(_APPNAME)
 else
 # Every other platform just winds up in dist/bin
 BINPATH = bin
 endif
@@ -171,17 +171,17 @@ DEFINES += -DICU_DATA_FILE=$(ICU_DATA_FI
 ifdef CLANG_CXX
 DEFINES += -DCLANG_CXX
 endif
 ifdef CLANG_CL
 DEFINES += -DCLANG_CL
 endif
 
 libs::
-	$(MAKE) -C $(DEPTH)/mail/locales langpack
+	$(MAKE) -C $(DEPTH)/$(MOZ_BUILD_APP)/locales langpack
 
 ifeq (WINNT,$(OS_ARCH))
 PKGCOMP_FIND_OPTS =
 else
 PKGCOMP_FIND_OPTS = -L
 endif
 ifeq (Darwin, $(OS_ARCH))
 FINDPATH = $(_APPNAME)/Contents/MacOS
@@ -198,12 +198,12 @@ ifdef MOZ_PKG_MANIFEST_P
 endif
 
 installer::
 ifdef INSTALLER_DIR
 	$(MAKE) -C $(INSTALLER_DIR)
 endif
 
 # The comm-* source stamp is already there.
-PLATFORM_SOURCE_STAMP = $(firstword $(shell hg -R "$(MOZILLA_SRCDIR)" parent --template="{node}\n" 2>/dev/null))
-PLATFORM_SOURCE_REPO = $(shell hg -R "$(MOZILLA_SRCDIR)" showconfig paths.default 2>/dev/null | sed -e "s/^ssh:/https:/")
+PLATFORM_SOURCE_STAMP = $(firstword $(shell hg -R "$(moztopsrcdir)" parent --template="{node}\n" 2>/dev/null))
+PLATFORM_SOURCE_REPO = $(shell hg -R "$(moztopsrcdir)" showconfig paths.default 2>/dev/null | sed -e "s/^ssh:/https:/")
 make-sourcestamp-file::
 	@echo "$(PLATFORM_SOURCE_REPO)/rev/$(PLATFORM_SOURCE_STAMP)" >> $(MOZ_SOURCESTAMP_FILE)
--- a/mail/installer/windows/Makefile.in
+++ b/mail/installer/windows/Makefile.in
@@ -1,16 +1,16 @@
 # 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/.
 
-include $(MOZILLA_SRCDIR)/toolkit/mozapps/installer/package-name.mk
+include $(moztopsrcdir)/toolkit/mozapps/installer/package-name.mk
 
 CONFIG_DIR = instgen
-SFX_MODULE = $(topsrcdir)/other-licenses/7zstub/thunderbird/7zSD.sfx
+SFX_MODULE = $(commtopsrcdir)/other-licenses/7zstub/thunderbird/7zSD.sfx
 
 DEFINES += -DMOZ_APP_VERSION=$(MOZ_APP_VERSION)
 PRE_RELEASE_SUFFIX := ""
 DEFINES += -DPRE_RELEASE_SUFFIX="$(PRE_RELEASE_SUFFIX)"
 
 ifdef MOZ_UPDATER
 DEFINES += -DMOZ_UPDATER=1
 endif
@@ -37,23 +37,23 @@ BRANDING_FILES = \
 	$(NULL)
 
 DEFINES += \
 	-DMOZ_APP_NAME=$(MOZ_APP_NAME) \
 	-DMOZ_APP_DISPLAYNAME='${MOZ_APP_DISPLAYNAME}' \
 	-DMOZILLA_VERSION=${MOZILLA_VERSION} \
 	$(NULL)
 
-include $(topsrcdir)/config/config.mk
+include $(moztopsrcdir)/config/config.mk
 
 ifdef LOCALE_MERGEDIR
 PPL_LOCALE_ARGS = \
   --l10n-dir=$(LOCALE_MERGEDIR)/mail/installer \
   --l10n-dir=$(call EXPAND_LOCALE_SRCDIR,mail/locales)/installer \
-  --l10n-dir=$(topsrcdir)/mail/locales/en-US/installer \
+  --l10n-dir=$(commtopsrcdir)/mail/locales/en-US/installer \
   $(NULL)
 else
 PPL_LOCALE_ARGS=$(call EXPAND_LOCALE_SRCDIR,mail/locales)/installer
 endif
 
 OVERRIDE_DEFAULT_GOAL := installer
 installer::
 	$(MAKE) -C .. installer-stage
@@ -62,35 +62,35 @@ installer::
 # For building the uninstaller during the application build so it can be
 # included for mar file generation.
 uninstaller::
 	$(RM) -r $(CONFIG_DIR) && mkdir $(CONFIG_DIR)
 	$(INSTALL) $(addprefix $(srcdir)/,$(INSTALLER_FILES)) $(CONFIG_DIR)
 	$(INSTALL) $(addprefix $(DIST)/branding/,$(BRANDING_FILES)) $(CONFIG_DIR)
 	$(call py_action,preprocessor,-Fsubstitution $(DEFINES) $(ACDEFINES) \
 	  $(srcdir)/nsis/defines.nsi.in -o $(CONFIG_DIR)/defines.nsi)
-	$(PYTHON) $(MOZILLA_SRCDIR)/toolkit/mozapps/installer/windows/nsis/preprocess-locale.py \
-	  --preprocess-locale $(MOZILLA_SRCDIR) \
+	$(PYTHON) $(moztopsrcdir)/toolkit/mozapps/installer/windows/nsis/preprocess-locale.py \
+	  --preprocess-locale $(moztopsrcdir) \
 	  $(PPL_LOCALE_ARGS) $(AB_CD) $(CONFIG_DIR)
 
 # For building the maintenanceservice installer
 ifdef MOZ_MAINTENANCE_SERVICE
 maintenanceservice_installer::
 	$(INSTALL) $(addprefix $(srcdir)/,$(INSTALLER_FILES)) $(CONFIG_DIR)
 	$(call py_action,preprocessor,-Fsubstitution $(DEFINES) $(ACDEFINES) \
 	  $(srcdir)/nsis/defines.nsi.in -o $(CONFIG_DIR)/defines.nsi)
-	$(PYTHON) $(MOZILLA_SRCDIR)/toolkit/mozapps/installer/windows/nsis/preprocess-locale.py \
-	  --preprocess-locale $(MOZILLA_SRCDIR) \
+	$(PYTHON) $(moztopsrcdir)/toolkit/mozapps/installer/windows/nsis/preprocess-locale.py \
+	  --preprocess-locale $(moztopsrcdir) \
 	  $(PPL_LOCALE_ARGS) $(AB_CD) $(CONFIG_DIR)
 endif
 
 $(CONFIG_DIR)/setup.exe::
 	$(RM) -r $(CONFIG_DIR) && mkdir $(CONFIG_DIR)
 	$(INSTALL) $(addprefix $(srcdir)/,$(INSTALLER_FILES)) $(CONFIG_DIR)
 	$(INSTALL) $(addprefix $(DIST)/branding/,$(BRANDING_FILES)) $(CONFIG_DIR)
 	$(call py_action,preprocessor,-Fsubstitution $(DEFINES) $(ACDEFINES) \
 	  $(srcdir)/nsis/defines.nsi.in -o $(CONFIG_DIR)/defines.nsi)
-	$(PYTHON) $(MOZILLA_SRCDIR)/toolkit/mozapps/installer/windows/nsis/preprocess-locale.py \
-	  --preprocess-locale $(MOZILLA_SRCDIR) \
+	$(PYTHON) $(moztopsrcdir)/toolkit/mozapps/installer/windows/nsis/preprocess-locale.py \
+	  --preprocess-locale $(moztopsrcdir) \
 	  $(PPL_LOCALE_ARGS) $(AB_CD) $(CONFIG_DIR)
 
-include $(topsrcdir)/config/rules.mk
-include $(MOZILLA_SRCDIR)/toolkit/mozapps/installer/windows/nsis/makensis.mk
+include $(moztopsrcdir)/config/rules.mk
+include $(moztopsrcdir)/toolkit/mozapps/installer/windows/nsis/makensis.mk
--- a/mail/locales/Makefile.in
+++ b/mail/locales/Makefile.in
@@ -1,15 +1,15 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-include $(topsrcdir)/config/config.mk
+include $(moztopsrcdir)/config/config.mk
 
-_ABS_SRCDIR := $(abspath $(topsrcdir))
+_ABS_SRCDIR := $(abspath $(commtopsrcdir))
 
 SUBMAKEFILES += \
 	$(DEPTH)/$(MOZ_BRANDING_DIRECTORY)/Makefile \
 	$(DEPTH)/$(MOZ_BRANDING_DIRECTORY)/locales/Makefile \
 	$(NULL)
 
 # This makefile uses variable overrides from the libs-% target to
 # build non-default locales to non-default dist/ locations. Be aware!
@@ -31,18 +31,18 @@ PP_TARGETS += L10N_PREF_JS_EXPORTS
 
 ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
 MOZ_PKG_MAC_DSSTORE=$(ABS_DIST)/branding/dsstore
 MOZ_PKG_MAC_BACKGROUND=$(ABS_DIST)/branding/background.png
 MOZ_PKG_MAC_ICON=$(ABS_DIST)/branding/disk.icns
 MOZ_PKG_MAC_EXTRA=--symlink '/Applications:/ '
 endif
 
-MOZ_SFX_PACKAGE=$(topsrcdir)/other-licenses/7zstub/thunderbird/7zSD.sfx
-MOZ_INSTALLER_PATH=$(topsrcdir)/mail/installer/windows
+MOZ_SFX_PACKAGE=$(commtopsrcdir)/other-licenses/7zstub/thunderbird/7zSD.sfx
+MOZ_INSTALLER_PATH=$(commtopsrcdir)/mail/installer/windows
 
 ifeq (WINNT,$(OS_ARCH))
 UNINSTALLER_PACKAGE_HOOK = $(RM) -r $(STAGEDIST)/uninstall; \
     $(NSINSTALL) -D $(STAGEDIST)/uninstall; \
     cp ../installer/windows/l10ngen/helper.exe $(STAGEDIST)/uninstall; \
     $(RM) $(ABS_DIST)/l10n-stage/setup.exe; \
     cp ../installer/windows/l10ngen/setup.exe $(ABS_DIST)/l10n-stage; \
     $(NULL)
@@ -63,19 +63,19 @@ list-json = $(SEARCHPLUGINS_PATH)/list.j
 GARBAGE += $(list-json)
 
 libs:: searchplugins
 
 # Required for l10n.mk - defines a list of app sub dirs that should
 # be included in langpack xpis.
 DIST_SUBDIRS = $(DIST_SUBDIR)
 
-include $(topsrcdir)/config/rules.mk
+include $(moztopsrcdir)/config/rules.mk
 
-include $(topsrcdir)/mozilla/toolkit/locales/l10n.mk
+include $(moztopsrcdir)/toolkit/locales/l10n.mk
 
 $(list-json): $(call mkdir_deps,$(SEARCHPLUGINS_PATH)) $(if $(IS_LANGUAGE_REPACK),FORCE)
 	$(call py_action,generate_searchjson,$(srcdir)/search/list.json $(AB_CD) $(list-json))
 searchplugins:: $(list-json)
 
 $(DIST)/branding:
 	$(NSINSTALL) -D $@
 
@@ -131,23 +131,23 @@ else
 	  sed -e 's/^InfoText=/Info=/' -e 's/^TitleText=/Title=/' | \
 	  sed -e 's/%MOZ_APP_DISPLAYNAME%/$(MOZ_APP_DISPLAYNAME)/' > \
 	  $(FINAL_TARGET)/updater.ini
 endif
 endif
 
 ident:
 	@printf 'comm_revision '
-	@$(PYTHON) $(MOZILLA_SRCDIR)/config/printconfigsetting.py \
+	@$(PYTHON) $(moztopsrcdir)/config/printconfigsetting.py \
 	    $(STAGEDIST)/application.ini App SourceStamp
 	@printf 'moz_revision '
-	@$(PYTHON) $(MOZILLA_SRCDIR)/config/printconfigsetting.py \
+	@$(PYTHON) $(moztopsrcdir)/config/printconfigsetting.py \
 	    $(STAGEDIST)/platform.ini Build SourceStamp
 	@printf 'buildid '
-	@$(PYTHON) $(MOZILLA_SRCDIR)/config/printconfigsetting.py \
+	@$(PYTHON) $(moztopsrcdir)/config/printconfigsetting.py \
 	    $(STAGEDIST)/application.ini App BuildID
 
 #These make targets call prepare-repackages by setting different UPLOAD_DIR
 prepare-upload-latest-%:
 	@$(MAKE) prepare-repackages-$* UPLOAD_DIR=$(DIST)/upload/latest
 
 prepare-upload-dated-%:
 	@$(MAKE) prepare-repackages-$* UPLOAD_DIR=$(DIST)/upload/`date "+%Y-%m-%d-%H"`-$(MOZ_PKG_APPNAME)$(MOZ_APP_VERSION)-l10n
@@ -177,31 +177,31 @@ ifeq (WINNT, $(OS_ARCH))
 	   "$(UPLOAD_DIR)/$(PKG_INST_PATH)$(PKG_INST_BASENAME).exe"
 endif
 # Set the permissions that the folders will have in ftp once uploaded
 	chmod -vR 775 $(UPLOAD_DIR)
 
 merge-%:
 ifdef LOCALE_MERGEDIR
 	$(RM) -rf $(LOCALE_MERGEDIR)
-	$(MOZILLA_SRCDIR)/mach compare-locales --merge-dir $(LOCALE_MERGEDIR) --l10n-ini $(srcdir)/l10n.ini $*
+	$(moztopsrcdir)/mach compare-locales --merge-dir $(LOCALE_MERGEDIR) --l10n-ini $(srcdir)/l10n.ini $*
 endif
 	@echo
 
 # test target, depends on make package
 # try to repack x-test, with just toolkit/defines.inc being there
 l10n-check::
 	$(RM) -rf x-test
 	$(NSINSTALL) -D x-test/toolkit
 	echo '#define MOZ_LANG_TITLE Just testing' > x-test/toolkit/defines.inc
 	$(MAKE) installers-x-test L10NBASEDIR='$(PWD)' LOCALE_MERGEDIR='$(PWD)/mergedir'
 
 ifdef MOZ_CALENDAR
-LIGHTNING_PATH=$(DEPTH)/calendar/lightning
-GDATA_PATH=$(DEPTH)/calendar/providers/gdata
+LIGHTNING_PATH=$(COMMDEPTH)/calendar/lightning
+GDATA_PATH=$(COMMDEPTH)/calendar/providers/gdata
 
 define run-calendar-rule
 $(MAKE) -C $(LIGHTNING_PATH) LOCALE_MERGEDIR=$(LOCALE_MERGEDIR) $(subst calendar-,,$@)
 $(MAKE) -C $(GDATA_PATH) LOCALE_MERGEDIR=$(LOCALE_MERGEDIR) $(subst calendar-,,$@)
 endef
 
 # Add calendar targets for pattern rules. Unfortunately multiple pattern rules
 # on the left hand side do something different with make, therefore we need to
--- a/mail/moz.build
+++ b/mail/moz.build
@@ -14,12 +14,12 @@ DIRS += [
     'themes',
     'app',
 ]
 
 if CONFIG['MAKENSISU']:
     DIRS += ['installer/windows']
 
 if CONFIG['MOZ_BUNDLED_FONTS']:
-    DIRS += ['/mozilla/browser/fonts']
+    DIRS += ['/%s/browser/fonts' % CONFIG['mozreltopsrcdir']]
 
 TEST_DIRS += ['test/mozmill']
 
--- a/mail/test/mozmill/Makefile.in
+++ b/mail/test/mozmill/Makefile.in
@@ -1,35 +1,35 @@
 #
 # 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/.
 
-include $(topsrcdir)/config/rules.mk
+include $(moztopsrcdir)/config/rules.mk
 
 # We're installing to _tests/mozmill
 _DEST_DIR = $(DEPTH)/_tests/mozmill
 
 $(_DEST_DIR):
 	$(NSINSTALL) -D $@
 
 
 # Copy MozMill and its dependencies over, and set up a virtualenv. The
 # virtualenv directory is outside because we don't want to bundle it up during
 # stage-package.
 VIRTUALENV_DIR = $(_DEST_DIR)/../mozmill-virtualenv
 mozmill-virtualenv: NSDISTMODE=copy
 mozmill-virtualenv: $(_DEST_DIR)
-	$(INSTALL) $(topsrcdir)/mail/test/resources $(_DEST_DIR)
-	$(INSTALL) $(topsrcdir)/mozilla/python/virtualenv $(_DEST_DIR)/resources/
+	$(INSTALL) $(commtopsrcdir)/mail/test/resources $(_DEST_DIR)
+	$(INSTALL) $(moztopsrcdir)/python/virtualenv $(_DEST_DIR)/resources/
 	rm -rf $(VIRTUALENV_DIR) && \
 	mkdir $(VIRTUALENV_DIR) && \
 	unset MACOSX_DEPLOYMENT_TARGET && \
 	$(PYTHON) $(_DEST_DIR)/resources/installmozmill.py $(VIRTUALENV_DIR) $(MOZILLA_DIR)/testing/mozbase
 
 libs:: mozmill-virtualenv
 
 PKG_STAGE = $(DIST)/test-stage
 
 stage-package:
 	$(NSINSTALL) -D $(PKG_STAGE)/mozmill/
-	@(cd $(topsrcdir)/mail/test/mozmill && tar $(TAR_CREATE_FLAGS) - *) | (cd $(PKG_STAGE)/mozmill/ && tar -xf -)
+	@(cd $(commtopsrcdir)/mail/test/mozmill && tar $(TAR_CREATE_FLAGS) - *) | (cd $(PKG_STAGE)/mozmill/ && tar -xf -)
 	@(cd $(DEPTH)/_tests/mozmill && tar $(TAR_CREATE_FLAGS) - *) | (cd $(PKG_STAGE)/mozmill/ && tar -xf -)
--- a/mail/test/mozmill/moz.build
+++ b/mail/test/mozmill/moz.build
@@ -5,13 +5,12 @@
 
 TEST_HARNESS_FILES.mozmill += [
     'mozmilltests.list',
     'runtest.py',
     'runtestlist.py',
 ]
 
 TEST_HARNESS_FILES.mozmill.resources += [
-    '/mail/base/test/unit/resources/**',
-    '/mailnews/test/fakeserver/**',
-    '/mailnews/test/resources/**',
+    '/%s/mail/base/test/unit/resources/**' % CONFIG['mozreltopsrcdir'],
+    '/%s/mailnews/test/fakeserver/**' % CONFIG['mozreltopsrcdir'],
+    '/%s/mailnews/test/resources/**' % CONFIG['mozreltopsrcdir'],
 ]
-
--- a/mail/testsuite-targets.mk
+++ b/mail/testsuite-targets.mk
@@ -26,41 +26,41 @@ check-no-solo = $(foreach solo,SOLO_TEST
 find-solo-test = $(if $(and $(SOLO_TEST),$(SOLO_FILE)),$(error Both SOLO_TEST and SOLO_FILE are specified. You may only specify one.),$(if $(SOLO_TEST),$(SOLO_TEST),$(if $(SOLO_FILE),$(SOLO_FILE),$(error SOLO_TEST or SOLO_FILE needs to be specified.))))
 
 # PYTHONHOME messes very badly with virtualenv setups, so unset it.
 mozmill:
 	$(call check-no-solo,SOLOVAR is specified. Perhaps you meant mozmill-one.)
 	unset PYTHONHOME && cd $(MOZMILLDIR) && MACOSX_DEPLOYMENT_TARGET= \
 	$(MOZMILLPYTHON) runtestlist.py --list=mozmilltests.list \
 	--binary=$(abspath $(BINARY)) \
-	--dir=$(abspath $(topsrcdir))/../mail/test/mozmill \
+	--dir=$(commtopsrcdir)/mail/test/mozmill \
 	--symbols-path=$(ABS_DIST)/crashreporter-symbols \
 	--plugins-path=$(ABS_DIST)/plugins \
 	--testing-modules-dir=$(topobjdir)/_tests/modules \
 	$(MOZMILL_EXTRA)
 
 mozmill-one: solo-test = $(find-solo-test)
 mozmill-one:
 	unset PYTHONHOME && cd $(MOZMILLDIR) && MACOSX_DEPLOYMENT_TARGET= \
 	$(MOZMILLPYTHON) runtest.py \
-	--test=$(abspath $(topsrcdir))/../mail/test/mozmill/$(solo-test) \
+	--test=$(commtopsrcdir)/mail/test/mozmill/$(solo-test) \
 	--binary=$(abspath $(BINARY)) \
 	--symbols-path=$(ABS_DIST)/crashreporter-symbols \
 	--plugins-path=$(ABS_DIST)/plugins \
 	--testing-modules-dir=$(topobjdir)/_tests/modules \
 	$(MOZMILL_EXTRA)
 
 # We need to add the mozmill tests to the package for tests.
 # If Lightning is enabled, also stage the lightning extension
 ifdef MOZ_CALENDAR
 package-tests: stage-mozmill stage-calendar
 else
 package-tests: stage-mozmill
 endif
 
 stage-mozmill: make-stage-dir
-	$(MAKE) -C $(DEPTH)/mail/test/mozmill stage-package
+	$(MAKE) -C $(COMMDEPTH)/mail/test/mozmill stage-package
 
 stage-calendar: make-stage-dir
-	$(MAKE) -C $(DEPTH)/calendar/lightning stage-package
-	$(MAKE) -C $(DEPTH)/calendar/providers/gdata stage-package
+	$(MAKE) -C $(COMMDEPTH)/calendar/lightning stage-package
+	$(MAKE) -C $(COMMDEPTH)/calendar/providers/gdata stage-package
 
 .PHONY: stage-mozmill stage-calendar
--- a/mailnews/base/test/moz.build
+++ b/mailnews/base/test/moz.build
@@ -7,11 +7,11 @@ XPCSHELL_TESTS_MANIFESTS += ['unit/xpcsh
 
 FINAL_LIBRARY = 'xul-gtest'
 
 UNIFIED_SOURCES += [
     'TestMailCookie.cpp',
 ]
 
 LOCAL_INCLUDES += [
-    '/mozilla/netwerk/test',
-    '/mozilla/xpcom/tests',
+    '/%s/netwerk/test' % CONFIG['mozreltopsrcdir'],
+    '/%s/xpcom/tests' % CONFIG['mozreltopsrcdir'],
 ]
--- a/mailnews/base/util/moz.build
+++ b/mailnews/base/util/moz.build
@@ -63,16 +63,16 @@ EXTRA_JS_MODULES += [
     'OAuth2.jsm',
     'OAuth2Providers.jsm',
     'StringBundle.js',
     'templateUtils.js',
     'traceHelper.js',
 ]
 
 LOCAL_INCLUDES += [
-  '/mozilla/netwerk/base'
+  '/%s/netwerk/base' % CONFIG['mozreltopsrcdir']
 ]
 
 FINAL_LIBRARY = 'mail'
 
 Library('msgbsutl_s')
 
 DEFINES['_IMPL_NS_MSG_BASE'] = True
--- a/mailnews/build/moz.build
+++ b/mailnews/build/moz.build
@@ -27,28 +27,28 @@ if CONFIG['OS_ARCH'] == 'WINNT':
 else:
     OS_LIBS += CONFIG['MOZ_ZLIB_LIBS']
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
     OS_LIBS += CONFIG['TK_LIBS']
     OS_LIBS += ['-framework Cocoa']
 
 LOCAL_INCLUDES += [
-    '/mailnews/addrbook/src',
-    '/mailnews/base/search/src',
-    '/mailnews/base/src',
-    '/mailnews/base/util',
-    '/mailnews/compose/src',
-    '/mailnews/extensions/bayesian-spam-filter/src',
-    '/mailnews/extensions/fts3/src',
-    '/mailnews/extensions/mailviews/src',
-    '/mailnews/extensions/mdn/src',
-    '/mailnews/extensions/smime/src',
-    '/mailnews/imap/src',
-    '/mailnews/intl',
-    '/mailnews/local/src',
-    '/mailnews/mime/emitters',
-    '/mailnews/mime/src',
-    '/mailnews/news/src',
+    '../addrbook/src',
+    '../base/search/src',
+    '../base/src',
+    '../base/util',
+    '../compose/src',
+    '../extensions/bayesian-spam-filter/src',
+    '../extensions/fts3/src',
+    '../extensions/mailviews/src',
+    '../extensions/mdn/src',
+    '../extensions/smime/src',
+    '../imap/src',
+    '../intl',
+    '../local/src',
+    '../mime/emitters',
+    '../mime/src',
+    '../news/src',
 ]
 
 if CONFIG['MOZ_LDAP_XPCOM']:
     DEFINES['MOZ_LDAP_XPCOM'] = True
--- a/mailnews/extensions/smime/src/moz.build
+++ b/mailnews/extensions/smime/src/moz.build
@@ -13,11 +13,11 @@ SOURCES += [
 EXTRA_COMPONENTS += [
     'smime-service.js',
     'smime-service.manifest',
 ]
 
 FINAL_LIBRARY = 'mail'
 
 LOCAL_INCLUDES += [
-    '/mozilla/security/manager/pki',
-    '/mozilla/security/pkix/include'
+    '/%s/security/manager/pki' % CONFIG['mozreltopsrcdir'],
+    '/%s/security/pkix/include' % CONFIG['mozreltopsrcdir']
 ]
--- a/mailnews/imap/test/moz.build
+++ b/mailnews/imap/test/moz.build
@@ -1,19 +1,19 @@
 # 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/.
 
 XPCSHELL_TESTS_MANIFESTS += ['unit/xpcshell.ini']
 
 LOCAL_INCLUDES += [
+   '../../base/util',
    '../src',
-   '/mailnews/base/util',
-   '/mozilla/xpcom/tests',
+   '/%s/xpcom/tests' % CONFIG['mozreltopsrcdir'],
 ]
 
 USE_LIBS += [
     'msgbsutl_s',
     'msgimap_s',
     'nspr',
     'xpcomglue_s',
     'xul',
--- a/mailnews/intl/moz.build
+++ b/mailnews/intl/moz.build
@@ -15,24 +15,24 @@ UNIFIED_SOURCES += [
     'nsUnicodeToMUTF7.cpp',
     'nsUnicodeToUTF7.cpp',
     'nsUTF7ToUnicode.cpp',
 ]
 
 XPIDL_MODULE = 'commuconv'
 
 LOCAL_INCLUDES += [
-    '/mozilla/intl/locale',
+    '/%s/intl/locale' % CONFIG['mozreltopsrcdir'],
 ]
 
 GENERATED_FILES += [
     'charsetalias.properties.h',
 ]
 charsetalias = GENERATED_FILES['charsetalias.properties.h']
-charsetalias.script = '../../mozilla/intl/locale/props2arrays.py'
+charsetalias.script = '/%s/intl/locale/props2arrays.py' % CONFIG['mozreltopsrcdir']
 charsetalias.inputs = ['charsetalias.properties']
 
 FINAL_LIBRARY = 'mail'
 
 # Tests need more attention before they can be enabled.
 TEST_DIRS += ['test']
 
 JAR_MANIFESTS += ['jar.mn']
--- a/mailnews/jsaccount/test/idl/moz.build
+++ b/mailnews/jsaccount/test/idl/moz.build
@@ -4,11 +4,16 @@
 # http://creativecommons.org/publicdomain/zero/1.0/
 
 XPIDL_SOURCES += [
   'msgIFooUrl.idl',
 ]
 
 XPIDL_MODULE = 'testJsAccount'
 
-TEST_HARNESS_FILES.xpcshell.mailnews.jsaccount.test.unit.resources += [
+if 'comm' in CONFIG['MOZ_BUILD_APP']:
+  test_harness_base = TEST_HARNESS_FILES.xpcshell.comm
+else:
+  test_harness_base = TEST_HARNESS_FILES.xpcshell
+
+test_harness_base.mailnews.jsaccount.test.unit.resources += [
     '!/dist/bin/components/testJsAccount.xpt',
 ]
--- a/mailnews/mailnews.mozbuild
+++ b/mailnews/mailnews.mozbuild
@@ -1,16 +1,15 @@
 # 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['MOZ_LDAP_XPCOM']:
     DIRS += [
-        '/ldap',
-        '/ldap/xpcom',
+        '/%s/ldap' % CONFIG['commreltopsrcdir'],
+        '/%s/ldap/xpcom' % CONFIG['commreltopsrcdir'],
     ]
 
 if CONFIG['MOZ_MORK']:
-    DIRS += ['/db']
+    DIRS += ['/%s/db' % CONFIG['commreltopsrcdir']]
 
-DIRS += ['/mailnews']
-
+DIRS += ['/%s/mailnews' % CONFIG['commreltopsrcdir']]
--- a/mailnews/mime/src/moz.build
+++ b/mailnews/mime/src/moz.build
@@ -65,19 +65,19 @@ SOURCES += [
     'nsCMS.cpp',
     'nsCMSSecureMessage.cpp',
     'nsMimeObjectClassAccess.cpp',
     'nsSimpleMimeConverterStub.cpp',
     'nsStreamConverter.cpp',
 ]
 
 LOCAL_INCLUDES += [
-     '/mozilla/security/certverifier',
-     '/mozilla/security/manager/ssl',
-     '/mozilla/security/pkix/include',
+     '/%s/security/certverifier' % CONFIG['mozreltopsrcdir'],
+     '/%s/security/manager/ssl' % CONFIG['mozreltopsrcdir'],
+     '/%s/security/pkix/include' % CONFIG['mozreltopsrcdir'],
 ]
 
 EXTRA_COMPONENTS += [
     'mimeJSComponents.js',
     'msgMime.manifest',
 ]
 
 EXTRA_JS_MODULES += [
--- a/mailnews/moz.build
+++ b/mailnews/moz.build
@@ -72,19 +72,24 @@ TESTING_JS_MODULES.mailnews += [
     'test/resources/IMAPpump.js',
     'test/resources/localAccountUtils.js',
     'test/resources/mailTestUtils.js',
     'test/resources/MockFactory.js',
     'test/resources/NetworkTestUtils.jsm',
     'test/resources/PromiseTestUtils.jsm',
 ]
 
-TEST_HARNESS_FILES.xpcshell.mailnews.data += [
-    '/mailnews/test/data/**',
+if 'comm' in CONFIG['MOZ_BUILD_APP']:
+  test_harness_base = TEST_HARNESS_FILES.xpcshell.comm
+else:
+  test_harness_base = TEST_HARNESS_FILES.xpcshell
+
+test_harness_base.mailnews.data += [
+    '/%s/mailnews/test/data/**' % CONFIG['commreltopsrcdir'],
 ]
 
-TEST_HARNESS_FILES.xpcshell.mailnews.resources += [
-    '/mailnews/test/resources/**',
+test_harness_base.mailnews.resources += [
+    '/%s/mailnews/test/resources/**' % CONFIG['commreltopsrcdir'],
 ]
 
 JS_PREFERENCE_PP_FILES += [
     'mailnews.js',
 ]
--- a/suite/Makefile.in
+++ b/suite/Makefile.in
@@ -1,25 +1,25 @@
 #
 # 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/.
 
-include $(topsrcdir)/config/rules.mk
+include $(moztopsrcdir)/config/rules.mk
 
 ifdef MAKENSISU
 # For Windows build the uninstaller during the application build since the
 # uninstaller is included with the application for mar file generation.
 libs::
 	$(MAKE) -C installer/windows uninstaller
 endif
 
 
 # As a fallout from bug 1247162, the sourcestamp in application.ini and
 # platform.ini are the same, which isn't a problem for Firefox, but
 # it's not right for anything else. So we correct platform.ini here.
 
-MOZ_REV=$(shell hg -R "$(MOZILLA_SRCDIR)" parent --template="{node}" 2>/dev/null)
+MOZ_REV=$(shell hg -R "$(moztopsrcdir)" parent --template="{node}" 2>/dev/null)
 
 libs:: $(DIST)/bin/platform.ini
 	sed -e "s/^\(SourceStamp=\).*/\1$(MOZ_REV)/" $(DIST)/bin/platform.ini \
 		> $(DIST)/bin/platform.ini~
 	mv -f $(DIST)/bin/platform.ini~ $(DIST)/bin/platform.ini
--- a/suite/app.mozbuild
+++ b/suite/app.mozbuild
@@ -1,27 +1,27 @@
 # 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/.
 
-include('/mailnews/mailnews.mozbuild')
+include('/%s/mailnews/mailnews.mozbuild' % CONFIG['commreltopsrcdir'])
 
 include('/toolkit/toolkit.mozbuild')
 
 if CONFIG['MOZ_EXTENSIONS']:
     DIRS += ['/extensions']
 
 if CONFIG['MOZ_COMPOSER']:
-    DIRS += ['/editor/ui']
+    DIRS += ['/%s/editor/ui' % CONFIG['commreltopsrcdir']]
 
 DIRS += ['/%s' % CONFIG['MOZ_BRANDING_DIRECTORY']]
 
 if CONFIG['MOZ_CALENDAR']:
     DIRS += [
-        '/calendar/lightning',
-        '/calendar/timezones'
+        '/%s/calendar/lightning' % CONFIG['commreltopsrcdir'],
+        '/%s/calendar/timezones' % CONFIG['commreltopsrcdir']
     ]
 
 DIRS += [
     '/xpfe/components/autocomplete',
-    '/suite',
+    '/%s/suite' % CONFIG['commreltopsrcdir'],
 ]
--- a/suite/app/Makefile.in
+++ b/suite/app/Makefile.in
@@ -18,17 +18,17 @@ else
 MOZ_WINCONSOLE = 0
 endif
 endif
 
 # This switches $(INSTALL) to copy mode, like $(SYSINSTALL), so things that
 # shouldn't get 755 perms need $(IFLAGS1) for either way of calling nsinstall.
 NSDISTMODE = copy
 
-include $(topsrcdir)/config/config.mk
+include $(moztopsrcdir)/config/config.mk
 
 # If we are trying to show an error dialog about the lack of SSE2 support,
 # make sure that code itself doesn't use SSE2.
 ifdef MOZ_LINUX_32_SSE2_STARTUP_ERROR
 CXXFLAGS := $(filter-out -march=% -msse -msse2 -mfpmath=sse,$(CXXFLAGS))
 CXX := $(filter-out -march=% -msse -msse2 -mfpmath=sse,$(CXX))
 CXXFLAGS += -mno-sse -mno-sse2 -mfpmath=387
 CXX += -march=pentiumpro
@@ -37,24 +37,24 @@ endif
 ifeq ($(OS_ARCH),WINNT)
 # Rebuild seamonkey.exe if the manifest changes - it's included by splash.rc.
 # (this dependency should really be just for seamonkey.exe, not other targets)
 # Note the manifest file exists in the tree, so we use the explicit filename
 # here.
 EXTRA_DEPS += seamonkey.exe.manifest
 endif
 
-include $(topsrcdir)/config/rules.mk
+include $(moztopsrcdir)/config/rules.mk
 
 libs::
 ifeq ($(OS_ARCH),WINNT)
 	$(EXIT_ON_ERROR) \
-	$(PERL) -pe 's/(?<!\r)\n/\r\n/g;' < $(topsrcdir)/suite/installer/license.txt > $(DIST)/bin/license.txt
+	$(PERL) -pe 's/(?<!\r)\n/\r\n/g;' < $(commtopsrcdir)/suite/installer/license.txt > $(DIST)/bin/license.txt
 else
-	$(INSTALL) $(IFLAGS1) $(topsrcdir)/suite/installer/license.txt $(DIST)/bin/
+	$(INSTALL) $(IFLAGS1) $(commtopsrcdir)/suite/installer/license.txt $(DIST)/bin/
 endif
 
 ifneq ($(OS_ARCH),WINNT)
 
 libs:: 
 	cp -p $(MOZ_APP_NAME)$(BIN_SUFFIX) $(DIST)/bin/$(MOZ_APP_NAME)-bin$(BIN_SUFFIX)
 
 endif
--- a/suite/app/moz.build
+++ b/suite/app/moz.build
@@ -3,41 +3,41 @@
 # 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/.
 
 GeckoProgram(CONFIG['MOZ_APP_NAME'])
 USE_LIBS += ['mozglue']
 SOURCES += ['nsSuiteApp.cpp']
 LOCAL_INCLUDES += [
     '!/build',
-    '/mozilla/toolkit/xre',
-    '/mozilla/xpcom/base',
-    '/mozilla/xpcom/build',
+    '/%s/toolkit/xre' % CONFIG['mozreltopsrcdir'],
+    '/%s/xpcom/base' % CONFIG['mozreltopsrcdir'],
+    '/%s/xpcom/build' % CONFIG['mozreltopsrcdir'],
 ]
 
 if CONFIG['OS_ARCH'] == 'WINNT':
     RCINCLUDE = 'splash.rc'
     DEFINES['MOZ_SUITE'] = True
 
 if CONFIG['LIBFUZZER']:
     USE_LIBS += [ 'fuzzer' ]
     LOCAL_INCLUDES += [
-        '/mozilla//tools/fuzzing/libfuzzer',
+        '/%s/tools/fuzzing/libfuzzer' % CONFIG['mozreltopsrcdir'],
     ]
 
 if CONFIG['_MSC_VER']:
     # Always enter a Windows program through wmain, whether or not we're
     # a console application.
     WIN32_EXE_LDFLAGS += ['-ENTRY:wmainCRTStartup']
 
 if CONFIG['MOZ_SANDBOX'] and CONFIG['OS_ARCH'] == 'WINNT':
     # For sandbox includes and the include dependencies those have
     LOCAL_INCLUDES += [
-        '/mozilla/security/sandbox/chromium',
-        '/mozilla/security/sandbox/chromium-shim',
+        '/%s/security/sandbox/chromium' % CONFIG['mozreltopsrcdir'],
+        '/%s/security/sandbox/chromium-shim' % CONFIG['mozreltopsrcdir'],
     ]
 
     USE_LIBS += [
         'sandbox_s',
     ]
 
     DELAYLOAD_DLLS += [
         'winmm.dll',
--- a/suite/branding/nightly/Makefile.in
+++ b/suite/branding/nightly/Makefile.in
@@ -1,17 +1,17 @@
 #
 # 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/.
 
 # Note: mac icons are handled in /suite/app during the final application
 # packaging
 
-include $(topsrcdir)/config/rules.mk
+include $(moztopsrcdir)/config/rules.mk
 
 export::
 	$(NSINSTALL) -D $(DIST)/branding
 ifeq ($(OS_ARCH),WINNT)
 	cp $(srcdir)/icons/windows/seamonkey.ico      $(DIST)/branding/seamonkey.ico
 	cp $(srcdir)/icons/windows/html-file.ico      $(DIST)/branding/html-file.ico
 	cp $(srcdir)/package/windows/branding.nsi     $(DIST)/branding/branding.nsi
 	cp $(srcdir)/package/windows/wizHeader.bmp    $(DIST)/branding/wizHeader.bmp
--- a/suite/browser/Makefile.in
+++ b/suite/browser/Makefile.in
@@ -1,10 +1,10 @@
 #
 # 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/.
 
-include $(topsrcdir)/config/rules.mk
+include $(moztopsrcdir)/config/rules.mk
 
 # channel-prefs.js is handled separate from other prefs due to bug 756325.
 libs:: $(srcdir)/channel-prefs.js
 	$(call py_action,preprocessor,-Fsubstitution $(PREF_PPFLAGS) $(ACDEFINES) $^ -o $(DIST)/bin/defaults/pref/channel-prefs.js)
--- a/suite/build/Makefile.in
+++ b/suite/build/Makefile.in
@@ -1,8 +1,8 @@
 # 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/.
 
-include $(topsrcdir)/config/rules.mk
+include $(moztopsrcdir)/config/rules.mk
 
 # Ensure that we don't embed a manifest referencing the CRT.
 EMBED_MANIFEST_AT =
--- a/suite/build/moz.build
+++ b/suite/build/moz.build
@@ -10,20 +10,20 @@ EXPORTS += [
 SOURCES += [
     'nsSuiteModule.cpp',
 ]
 
 Library('suite')
 FINAL_LIBRARY = 'xul'
 
 LOCAL_INCLUDES += [
-    '/suite/feeds/src',
-    '/suite/profile',
-    '/suite/profile/migration/src',
-    '/suite/shell/src',
+    '../feeds/src',
+    '../profile',
+    '../profile/migration/src',
+    '../shell/src',
 ]
 
 if CONFIG['OS_ARCH'] == 'WINNT':
     OS_LIBS += [
         'ole32',
         'shell32',
     ]
 
--- a/suite/common/jar.mn
+++ b/suite/common/jar.mn
@@ -1,8 +1,10 @@
+#filter substitution
+
 comm.jar:
 % content communicator %content/communicator/ contentaccessible=yes
 % content help %content/communicator/helpviewer/
 % override chrome://global/content/license.html chrome://communicator/content/license.html
 % override chrome://mozapps/content/profile/profileSelection.xul chrome://communicator/content/profile/profileSelection.xul
 % overlay chrome://global/content/viewSource.xul chrome://communicator/content/viewSourceOverlay.xul
 % overlay chrome://global/content/viewPartialSource.xul chrome://communicator/content/viewSourceOverlay.xul
 % overlay chrome://editor/content/EdAdvancedEdit.xul chrome://communicator/content/helpEditorOverlay.xul
@@ -67,19 +69,19 @@ comm.jar:
    content/communicator/defaultClientDialog.js
    content/communicator/defaultClientDialog.xul
    content/communicator/findUtils.js
    content/communicator/fullscreen-video.xhtml
    content/communicator/gopherAddon.xhtml
    content/communicator/helpEditorOverlay.xul
    content/communicator/helpMessengerOverlay.xul
    content/communicator/helpSecurityOverlay.xul
-   content/communicator/labelsencodings.properties                  (/mozilla/dom/encoding/labelsencodings.properties)
+   content/communicator/labelsencodings.properties                  (/@mozreltopsrcdir@/dom/encoding/labelsencodings.properties)
 # the following file is a suite-specific override of the generic license.html, using suite/common/app-license.html as input:
-*  content/communicator/license.html                                (/mozilla/toolkit/content/license.html)
+*  content/communicator/license.html                                (/@mozreltopsrcdir@/toolkit/content/license.html)
    content/communicator/nsContextMenu.js
    content/communicator/openLocation.js
    content/communicator/openLocation.xul
    content/communicator/passwordManager.xul
    content/communicator/safeMode.js
    content/communicator/safeMode.xul
    content/communicator/sanitize.xul
    content/communicator/setDesktopBackground.js
--- a/suite/common/moz.build
+++ b/suite/common/moz.build
@@ -36,10 +36,10 @@ XPCSHELL_TESTS_MANIFESTS += [
 JAR_MANIFESTS += ['jar.mn']
 
 # DEFINES for preprocessing
 # Use suite/common/app-license.html as input when generating 
 # chrome://content/communicator/license.html to override 
 # chrome://global/content/license.html (about:license)
 DEFINES['APP_LICENSE_BLOCK'] = '%s/app-license.html' % SRCDIR
 
-for var in ('MOZ_APP_NAME', 'MOZ_MACBUNDLE_NAME'):
+for var in ('MOZ_APP_NAME', 'MOZ_MACBUNDLE_NAME', 'mozreltopsrcdir'):
     DEFINES[var] = CONFIG[var]
--- a/suite/configure.in
+++ b/suite/configure.in
@@ -7,16 +7,41 @@ dnl file, You can obtain one at http://m
 dnl Things we need to carry from confvars.sh
 AC_DEFINE(MOZ_SUITE)
 AC_SUBST(MOZ_SUITE)
 AC_SUBST(MOZ_COMPOSER)
 AC_SUBST(SEAMONKEY_VERSION)
 AC_DEFINE(MOZ_SEPARATE_MANIFEST_FOR_THEME_OVERRIDES)
 AC_SUBST(MOZ_BUNDLED_FONTS)
 
+dnl Set up variables based on if either the mozilla repo is the
+dnl subdirectory or the comm repo.
+if test "$MOZ_BUILD_APP" = "comm/suite"
+then
+  dnl we are building with comm/ as the subdirectory
+  dnl $srcdir is the mozilla repo, comm is in the subdir
+  moztopsrcdir=$srcdir
+  commtopsrcdir=$srcdir/comm
+
+  mozreltopsrcdir=.
+  commreltopsrcdir=comm
+else
+  dnl we are building with mozilla/ as the subdirectory
+  dnl $srcdir is still the mozilla repo, so use the parent for comm
+  moztopsrcdir=$srcdir
+  commtopsrcdir=$srcdir/..
+
+  mozreltopsrcdir=mozilla
+  commreltopsrcdir=.
+fi
+AC_SUBST(moztopsrcdir)
+AC_SUBST(commtopsrcdir)
+AC_SUBST(mozreltopsrcdir)
+AC_SUBST(commreltopsrcdir)
+
 dnl Optional parts of the build.
 AC_SUBST(MOZ_MORK)
 if test "$MOZ_MORK"; then
   AC_DEFINE(MOZ_MORK)
 fi
 if test "$OS_ARCH" != "WINNT"; then
   MOZ_MOVEMAIL=1
   HAVE_MOVEMAIL=1
--- a/suite/confvars.sh
+++ b/suite/confvars.sh
@@ -5,18 +5,18 @@
 
 MOZ_APP_BASENAME=SeaMonkey
 MOZ_APP_VENDOR=Mozilla
 MOZ_APP_NAME=seamonkey
 MOZ_APP_DISPLAYNAME=SeaMonkey
 MOZ_LDAP_XPCOM=1
 MOZ_COMPOSER=1
 MOZ_SUITE=1
-MOZ_BRANDING_DIRECTORY=suite/branding/nightly
-MOZ_OFFICIAL_BRANDING_DIRECTORY=suite/branding/nightly
+MOZ_BRANDING_DIRECTORY=$MOZ_BUILD_APP/branding/nightly
+MOZ_OFFICIAL_BRANDING_DIRECTORY=$MOZ_BUILD_APP/branding/nightly
 MOZ_EXTENSIONS_DEFAULT=" inspector irc"
 MOZ_UPDATER=1
 # This should usually be the same as the value MAR_CHANNEL_ID.
 # If more than one ID is needed, then you should use a comma separated list
 # of values.
 ACCEPTED_MAR_CHANNEL_IDS=seamonkey-comm-central
 # The MAR_CHANNEL_ID must not contain the following 3 characters: ",\t "
 MAR_CHANNEL_ID=seamonkey-comm-central
--- a/suite/installer/Makefile.in
+++ b/suite/installer/Makefile.in
@@ -1,28 +1,28 @@
 # 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/.
 
 STANDALONE_MAKEFILE := 1
 
-include $(topsrcdir)/config/rules.mk
+include $(moztopsrcdir)/config/rules.mk
 
 MOZ_PKG_REMOVALS = $(srcdir)/removed-files.in
 
 MOZ_PKG_MANIFEST_P = $(srcdir)/package-manifest.in
 # Be fatal, except when building with XULRunner which already bundles some files.
 ifndef SYSTEM_LIBXUL
 MOZ_PKG_FATAL_WARNINGS = 1
 endif
 
 MOZ_PKG_DUPEFLAGS = \
 	-w \
 	-f $(srcdir)/allowed-dupes.mn \
-	-f $(MOZILLA_DIR)/browser/installer/allowed-dupes.mn \
+	-f $(moztopsrcdir)/browser/installer/allowed-dupes.mn \
 	$(NULL)
 
 MOZ_NONLOCALIZED_PKG_LIST = \
 	xpcom \
 	browser \
 	mail \
 	$(NULL)
 
@@ -153,17 +153,17 @@ endif
 NON_OMNIJAR_FILES = \
 	defaults/messenger/mailViews.dat \
 	defaults/profile/panels.rdf \
 	defaults/profile/mimeTypes.rdf \
 	defaults/profile/chrome/userChrome-example.css \
 	defaults/profile/chrome/userContent-example.css \
 	$(NULL)
 
-include $(MOZILLA_SRCDIR)/toolkit/mozapps/installer/packager.mk
+include $(moztopsrcdir)/toolkit/mozapps/installer/packager.mk
 
 ifeq (Darwin, $(OS_ARCH))
 BINPATH = $(_BINPATH)
 DEFINES += -DAPPNAME=$(_APPNAME)
 else
 BINPATH = bin
 endif
 DEFINES += -DBINPATH=$(BINPATH)
@@ -226,12 +226,12 @@ ifdef MOZ_PKG_MANIFEST_P
 endif
 
 installer:
 ifdef INSTALLER_DIR
 	$(MAKE) -C $(INSTALLER_DIR)
 endif
 
 # The comm-* source stamp is already there.
-PLATFORM_SOURCE_STAMP = $(firstword $(shell hg -R "$(MOZILLA_SRCDIR)" parent --template="{node|short}\n" 2>/dev/null))
-PLATFORM_SOURCE_REPO = $(shell hg -R "$(MOZILLA_SRCDIR)" showconfig paths.default 2>/dev/null | sed -e "s/^ssh:/https:/")
+PLATFORM_SOURCE_STAMP = $(firstword $(shell hg -R "$(moztopsrcdir)" parent --template="{node|short}\n" 2>/dev/null))
+PLATFORM_SOURCE_REPO = $(shell hg -R "$(moztopsrcdir)" showconfig paths.default 2>/dev/null | sed -e "s/^ssh:/https:/")
 make-sourcestamp-file::
 	@echo "$(PLATFORM_SOURCE_REPO)/rev/$(PLATFORM_SOURCE_STAMP)" >> $(MOZ_SOURCESTAMP_FILE)
--- a/suite/installer/windows/Makefile.in
+++ b/suite/installer/windows/Makefile.in
@@ -1,16 +1,16 @@
 # 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/.
 
-include $(MOZILLA_SRCDIR)/toolkit/mozapps/installer/package-name.mk
+include $(moztopsrcdir)/toolkit/mozapps/installer/package-name.mk
 
 CONFIG_DIR = instgen
-SFX_MODULE = $(topsrcdir)/other-licenses/7zstub/seamonkey/7zSD.sfx
+SFX_MODULE = $(commtopsrcdir)/other-licenses/7zstub/seamonkey/7zSD.sfx
 
 INSTALLER_FILES = \
 	app.tag \
 	nsis/installer.nsi \
 	nsis/uninstaller.nsi \
 	nsis/shared.nsh \
 	nsis/custom.nsi \
 	$(NULL)
@@ -21,41 +21,41 @@ BRANDING_FILES = \
 	wizHeaderRTL.bmp \
 	wizWatermark.bmp \
 	$(NULL)
 
 ifdef MOZ_UPDATER
 DEFINES += -DMOZ_UPDATER=1
 endif
 
-include $(topsrcdir)/config/config.mk
+include $(moztopsrcdir)/config/config.mk
 
 OVERRIDE_DEFAULT_GOAL := installer
 installer::
 	$(MAKE) -C .. installer-stage
 	$(MAKE) $(CONFIG_DIR)/setup.exe
 
 # For building the uninstaller during the application build so it can be
 # included for mar file generation.
 uninstaller::
 	$(RM) -r $(CONFIG_DIR) && mkdir $(CONFIG_DIR)
 	$(INSTALL) $(addprefix $(srcdir)/,$(INSTALLER_FILES)) $(CONFIG_DIR)
 	$(INSTALL) $(addprefix $(DIST)/branding/,$(BRANDING_FILES)) $(CONFIG_DIR)
 	$(call py_action,preprocessor,-Fsubstitution $(DEFINES) $(ACDEFINES) \
 	  $(srcdir)/nsis/defines.nsi.in -o $(CONFIG_DIR)/defines.nsi)
-	$(PYTHON) $(MOZILLA_SRCDIR)/toolkit/mozapps/installer/windows/nsis/preprocess-locale.py \
-	  --preprocess-locale $(MOZILLA_SRCDIR) \
+	$(PYTHON) $(moztopsrcdir)/toolkit/mozapps/installer/windows/nsis/preprocess-locale.py \
+	  --preprocess-locale $(moztopsrcdir) \
 	  $(call EXPAND_LOCALE_SRCDIR,suite/locales)/installer/windows $(AB_CD) $(CONFIG_DIR)
 
 $(CONFIG_DIR)/setup.exe::
 	$(RM) -r $(CONFIG_DIR) && mkdir $(CONFIG_DIR)
 	$(INSTALL) $(addprefix $(srcdir)/,$(INSTALLER_FILES)) $(CONFIG_DIR)
 	$(INSTALL) $(addprefix $(DIST)/branding/,$(BRANDING_FILES)) $(CONFIG_DIR)
-	$(PYTHON) $(MOZILLA_SRCDIR)/toolkit/mozapps/installer/windows/nsis/preprocess-locale.py \
-	  --convert-utf8-utf16le $(topsrcdir)/suite/installer/license.txt $(CONFIG_DIR)/license.txt
+	$(PYTHON) $(moztopsrcdir)/toolkit/mozapps/installer/windows/nsis/preprocess-locale.py \
+	  --convert-utf8-utf16le $(commtopsrcdir)/suite/installer/license.txt $(CONFIG_DIR)/license.txt
 	$(call py_action,preprocessor,-Fsubstitution $(DEFINES) $(ACDEFINES) \
 	  $(srcdir)/nsis/defines.nsi.in -o $(CONFIG_DIR)/defines.nsi)
-	$(PYTHON) $(MOZILLA_SRCDIR)/toolkit/mozapps/installer/windows/nsis/preprocess-locale.py \
-	  --preprocess-locale $(MOZILLA_SRCDIR) \
+	$(PYTHON) $(moztopsrcdir)/toolkit/mozapps/installer/windows/nsis/preprocess-locale.py \
+	  --preprocess-locale $(moztopsrcdir) \
 	  $(call EXPAND_LOCALE_SRCDIR,suite/locales)/installer/windows $(AB_CD) $(CONFIG_DIR)
 
-include $(topsrcdir)/config/rules.mk
-include $(MOZILLA_SRCDIR)/toolkit/mozapps/installer/windows/nsis/makensis.mk
+include $(moztopsrcdir)/config/rules.mk
+include $(moztopsrcdir)/toolkit/mozapps/installer/windows/nsis/makensis.mk
--- a/suite/locales/Makefile.in
+++ b/suite/locales/Makefile.in
@@ -1,15 +1,15 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-include $(topsrcdir)/config/config.mk
+include $(moztopsrcdir)/config/config.mk
 
-_ABS_SRCDIR := $(abspath $(topsrcdir))
+_ABS_SRCDIR := $(abspath $(commtopsrcdir))
 
 vpath %.xml @srcdir@/en-US/searchplugins
 vpath %.xml $(LOCALE_SRCDIR)/searchplugins
 
 SUBMAKEFILES += \
 	$(DEPTH)/$(MOZ_BRANDING_DIRECTORY)/Makefile \
 	$(NULL)
 
@@ -33,18 +33,18 @@ PP_TARGETS += L10N_PREF_JS_EXPORTS
 
 ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa)
 MOZ_PKG_MAC_DSSTORE=$(ABS_DIST)/branding/dsstore
 MOZ_PKG_MAC_BACKGROUND=$(ABS_DIST)/branding/background.png
 MOZ_PKG_MAC_ICON=$(ABS_DIST)/branding/disk.icns
 MOZ_PKG_MAC_EXTRA=--symlink '/Applications:/ '
 endif
 
-MOZ_SFX_PACKAGE=$(topsrcdir)/other-licenses/7zstub/seamonkey/7zSD.sfx
-MOZ_INSTALLER_PATH=$(topsrcdir)/suite/installer/windows
+MOZ_SFX_PACKAGE=$(commtopsrcdir)/other-licenses/7zstub/seamonkey/7zSD.sfx
+MOZ_INSTALLER_PATH=$(commtopsrcdir)/suite/installer/windows
 
 ifeq (WINNT,$(OS_ARCH))
 UNINSTALLER_PACKAGE_HOOK = $(RM) -r $(STAGEDIST)/uninstall; \
 	$(NSINSTALL) -D $(STAGEDIST)/uninstall; \
 	cp ../installer/windows/l10ngen/helper.exe $(STAGEDIST)/uninstall; \
 	$(RM) $(ABS_DIST)/l10n-stage/setup.exe; \
 	cp ../installer/windows/l10ngen/setup.exe $(ABS_DIST)/l10n-stage; \
 	$(NULL)
@@ -63,19 +63,19 @@ SEARCH_PLUGINS_PATH := $(FINAL_TARGET)/s
 .PHONY: searchplugins
 SEARCH_PLUGINS_TARGET := libs searchplugins
 SEARCH_PLUGINS := $(foreach plugin,$(addsuffix .xml,$(SEARCH_PLUGINS_NAMES)),$(or $(wildcard $(call MERGE_FILE,searchplugins/$(plugin))),$(info Missing searchplugin: $(plugin))))
 # Some locale-specific search plugins may have preprocessor directives, but the
 # default en-US ones do not.
 SEARCH_PLUGINS_FLAGS := --silence-missing-directive-warnings 
 PP_TARGETS += SEARCH_PLUGINS
 
-include $(topsrcdir)/config/rules.mk
+include $(moztopsrcdir)/config/rules.mk
 
-include $(topsrcdir)/mozilla/toolkit/locales/l10n.mk
+include $(moztopsrcdir)/toolkit/locales/l10n.mk
 
 $(DIST)/branding:
 	$(NSINSTALL) -D $@
 
 PROFILE_CHROME = userChrome-example.css userContent-example.css
 
 NO_JA_JP_MAC_AB_CD := $(if $(filter ja-JP-mac, $(AB_CD)),ja,$(AB_CD))
 
@@ -179,29 +179,29 @@ endif
 
 ifdef MOZ_CRASHREPORTER
 libs:: $(call MERGE_FILE,crashreporter/crashreporter-override.ini)
 	$(SYSINSTALL) $(IFLAGS1) $^ $(FINAL_TARGET)
 endif
 
 ident:
 	@printf 'comm_revision '
-	@$(PYTHON) $(MOZILLA_SRCDIR)/config/printconfigsetting.py \
+	@$(PYTHON) $(moztopsrcdir)/config/printconfigsetting.py \
 	    $(STAGEDIST)/application.ini App SourceStamp
 	@printf 'moz_revision '
-	@$(PYTHON) $(MOZILLA_SRCDIR)/config/printconfigsetting.py \
+	@$(PYTHON) $(moztopsrcdir)/config/printconfigsetting.py \
 	    $(STAGEDIST)/platform.ini Build SourceStamp
 	@printf 'buildid '
-	@$(PYTHON) $(MOZILLA_SRCDIR)/config/printconfigsetting.py \
+	@$(PYTHON) $(moztopsrcdir)/config/printconfigsetting.py \
 	    $(STAGEDIST)/application.ini App BuildID
 
 merge-%:
 ifdef LOCALE_MERGEDIR
 	$(RM) -rf $(LOCALE_MERGEDIR)
-	$(topsrcdir)/mozilla/mach compare-locales --merge-dir $(LOCALE_MERGEDIR) --l10n-ini $(srcdir)/l10n.ini $*
+	$(moztopsrcdir)/mach compare-locales --merge-dir $(LOCALE_MERGEDIR) --l10n-ini $(srcdir)/l10n.ini $*
 endif
 	@echo
 
 .PHONY: repackage-extensions
 
 MOZ_PKG_EXTRAL10N += extensions/langpack-$(AB_CD)@chatzilla.mozilla.org=$(DIST)/xpi-stage/chatzilla-$(AB_CD)
 
 ifdef MOZ_CALENDAR
--- a/suite/moz.build
+++ b/suite/moz.build
@@ -25,16 +25,16 @@ DIRS += [
     'shell/src',
     'smile',
 ]
 
 if CONFIG['MAKENSISU']:
     DIRS += ['installer/windows']
 
 if CONFIG['MOZ_BUNDLED_FONTS']:
-    DIRS += ['/mozilla/browser/fonts']
+    DIRS += ['/%s/browser/fonts' % CONFIG['mozreltopsrcdir']]
 
 # app is always last as it packages up the built files on mac.
 DIRS += [
     'build',
     'app',
 ]
 
--- a/suite/themes/modern/jar.mn
+++ b/suite/themes/modern/jar.mn
@@ -1,12 +1,14 @@
 # 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/.
 
+#filter substitution
+
 modern.jar:
 % override chrome://mozapps/skin/places/defaultFavicon.png chrome://communicator/skin/bookmarks/bookmark-item.png
 % skin communicator modern/1.0 %skin/modern/communicator/
 % skin editor modern/1.0 %skin/modern/editor/
 % skin global modern/1.0 %skin/modern/global/
 % skin global-platform modern/1.0 %skin/modern/global/
 % skin messenger modern/1.0 %skin/modern/messenger/
 % skin mozapps modern/1.0 %skin/modern/mozapps/
@@ -269,17 +271,17 @@ modern.jar:
   skin/modern/global/dirListing/dirListing.css                     (global/dirListing/dirListing.css)
   skin/modern/global/filepicker/blank.gif                          (global/filepicker/blank.gif)
   skin/modern/global/filepicker/dir-closed.gif                     (global/filepicker/dir-closed.gif)
   skin/modern/global/filepicker/dir-open.gif                       (global/filepicker/dir-open.gif)
   skin/modern/global/filepicker/folder-up.gif                      (global/filepicker/folder-up.gif)
   skin/modern/global/filepicker/folder-home.gif                    (global/filepicker/folder-home.gif)
   skin/modern/global/filepicker/folder-new.gif                     (global/filepicker/folder-new.gif)
   skin/modern/global/icons/authentication-48.png                   (global/icons/authentication-48.png)
-  skin/modern/global/icons/autoscroll.png                          (/mozilla/toolkit/themes/windows/global/icons/autoscroll.png)
+  skin/modern/global/icons/autoscroll.png                          (/@mozreltopsrcdir@/toolkit/themes/windows/global/icons/autoscroll.png)
   skin/modern/global/icons/blacklist_favicon.png                   (global/icons/blacklist_favicon.png)
   skin/modern/global/icons/blacklist_large.png                     (global/icons/blacklist_large.png)
   skin/modern/global/icons/close-act.gif                           (global/icons/close-act.gif)
   skin/modern/global/icons/close-dis.gif                           (global/icons/close-dis.gif)
   skin/modern/global/icons/close-hov.gif                           (global/icons/close-hov.gif)
   skin/modern/global/icons/close.gif                               (global/icons/close.gif)
   skin/modern/global/icons/closebox.gif                            (global/icons/closebox.gif)
   skin/modern/global/icons/Error.png                               (global/icons/Error.png)
@@ -309,30 +311,30 @@ modern.jar:
   skin/modern/global/icons/sslWarning.png                          (global/icons/sslWarning.png)
   skin/modern/global/icons/warning-16.png                          (global/icons/warning-16.png)
   skin/modern/global/icons/warning-24.png                          (global/icons/warning-24.png)
   skin/modern/global/icons/warning-32.png                          (global/icons/warning-32.png)
   skin/modern/global/icons/warning-48.png                          (global/icons/warning-48.png)
   skin/modern/global/icons/warning-64.png                          (global/icons/warning-64.png)
   skin/modern/global/icons/wrap.png                                (global/icons/wrap.png)
   skin/modern/global/media/checkerboard.png                        (global/media/checkerboard.png)
-  skin/modern/global/media/clicktoplay-bgtexture.png               (/mozilla/toolkit/themes/shared/media/clicktoplay-bgtexture.png)
-  skin/modern/global/media/error.png                               (/mozilla/toolkit/themes/shared/media/error.png)
+  skin/modern/global/media/clicktoplay-bgtexture.png               (/@mozreltopsrcdir@/toolkit/themes/shared/media/clicktoplay-bgtexture.png)
+  skin/modern/global/media/error.png                               (/@mozreltopsrcdir@/toolkit/themes/shared/media/error.png)
   skin/modern/global/media/muteButton.png                          (global/media/muteButton.png)
   skin/modern/global/media/pauseButton.png                         (global/media/pauseButton.png)
   skin/modern/global/media/playButton.png                          (global/media/playButton.png)
   skin/modern/global/media/scrubberThumb.png                       (global/media/scrubberThumb.png)
   skin/modern/global/media/scrubberThumbWide.png                   (global/media/scrubberThumbWide.png)
-  skin/modern/global/media/throbber.png                            (/mozilla/toolkit/themes/shared/media/throbber.png)
+  skin/modern/global/media/throbber.png                            (/@mozreltopsrcdir@/toolkit/themes/shared/media/throbber.png)
   skin/modern/global/media/stalled.png                             (global/media/stalled.png)
   skin/modern/global/media/TopLevelImageDocument.css               (global/media/TopLevelImageDocument.css)
   skin/modern/global/media/TopLevelVideoDocument.css               (global/media/TopLevelVideoDocument.css)
   skin/modern/global/media/unmuteButton.png                        (global/media/unmuteButton.png)
   skin/modern/global/media/videocontrols.css                       (global/media/videocontrols.css)
-  skin/modern/global/media/videoClickToPlayButton.svg              (/mozilla/toolkit/themes/shared/media/videoClickToPlayButton.svg)
+  skin/modern/global/media/videoClickToPlayButton.svg              (/@mozreltopsrcdir@/toolkit/themes/shared/media/videoClickToPlayButton.svg)
   skin/modern/global/menu/menu-arrow-dis.gif                       (global/menu/menu-arrow-dis.gif)
   skin/modern/global/menu/menu-arrow-hov.gif                       (global/menu/menu-arrow-hov.gif)
   skin/modern/global/menu/menu-arrow.gif                           (global/menu/menu-arrow.gif)
   skin/modern/global/menu/menu-check-dis.gif                       (global/menu/menu-check-dis.gif)
   skin/modern/global/menu/menu-check-hov.gif                       (global/menu/menu-check-hov.gif)
   skin/modern/global/menu/menu-check.gif                           (global/menu/menu-check.gif)
   skin/modern/global/menu/menu-radio-dis.gif                       (global/menu/menu-radio-dis.gif)
   skin/modern/global/menu/menu-radio-hov.gif                       (global/menu/menu-radio-hov.gif)
--- a/suite/themes/modern/moz.build
+++ b/suite/themes/modern/moz.build
@@ -7,13 +7,14 @@ FINAL_TARGET_PP_FILES += ['install.rdf']
 
 DIST_SUBDIR = 'extensions/modern@themes.mozilla.org'
 
 JAR_MANIFESTS += ['jar.mn']
 
 USE_EXTENSION_MANIFEST = True
 
 DEFINES['SEAMONKEY_VERSION'] = CONFIG['SEAMONKEY_VERSION']
+DEFINES['mozreltopsrcdir'] = CONFIG['mozreltopsrcdir']
 
 FINAL_TARGET_FILES += [
     'icon.png',
     'preview.png',
 ]