Bug 488175 - flatten dist/include and provide mechanism to install certain headers in namespaced subdirectories (e.g. #include "mozilla/XPCOM.h") r=ted
authorBenjamin Smedberg <benjamin@smedbergs.us>
Mon, 18 May 2009 14:15:05 -0400
changeset 28510 a6b13b312e780d7825ef07111c5e740604ac8e9a
parent 28509 9703fd69e126b1969ada29a123bcb59448703de8
child 28511 ad628ca8eddba49930c70b737173922e4eaac85f
push idunknown
push userunknown
push dateunknown
reviewersted
bugs488175
milestone1.9.2a1pre
Bug 488175 - flatten dist/include and provide mechanism to install certain headers in namespaced subdirectories (e.g. #include "mozilla/XPCOM.h") r=ted
config/config.mk
config/nspr/Makefile.in
config/rules.mk
content/media/video/public/nsMediaDecoder.h
content/media/video/public/nsMediaStream.h
content/media/video/src/nsMediaCache.cpp
embedding/components/printingui/src/mac/printpde/Makefile.in
gfx/cairo/cairo/src/Makefile.in
gfx/src/thebes/Makefile.in
js/src/config/config.mk
js/src/config/rules.mk
media/libfishsound/include/fishsound/Makefile.in
media/libogg/include/ogg/Makefile.in
media/liboggplay/include/oggplay/Makefile.in
media/liboggplay/src/liboggplay/Makefile.in
media/liboggz/include/oggz/Makefile.in
media/liboggz/src/liboggz/Makefile.in
media/libsydneyaudio/include/Makefile.in
media/libsydneyaudio/src/Makefile.in
media/libtheora/include/theora/Makefile.in
media/libvorbis/include/vorbis/Makefile.in
modules/plugin/default/mac/DefaultPlugin.xcodeproj/project.pbxproj
modules/plugin/default/mac/Makefile.in
modules/zlib/src/Makefile.in
modules/zlib/src/objs.mk
modules/zlib/standalone/Makefile.in
security/manager/Makefile.in
storage/public/Makefile.in
storage/src/Makefile.in
toolkit/mozapps/installer/packager.mk
toolkit/mozapps/update/src/updater/Makefile.in
widget/src/windows/Makefile.in
xpcom/build/Makefile.in
xpcom/build/XPCOM.h
xpcom/build/nsXPComInit.cpp
xpcom/ds/Makefile.in
xpcom/ds/TimeStamp.cpp
xpcom/ds/TimeStamp.h
xpcom/ds/nsTimeStamp.cpp
xpcom/ds/nsTimeStamp.h
xpcom/glue/Makefile.in
xpcom/reflect/xptcall/src/md/unix/Makefile.in
xpcom/tests/TestTimeStamp.cpp
xulrunner/installer/Makefile.in
xulrunner/installer/libxul-embedding-unstable.pc.in
xulrunner/installer/libxul-embedding.pc.in
xulrunner/installer/libxul-unstable.pc.in
xulrunner/installer/libxul.pc.in
--- a/config/config.mk
+++ b/config/config.mk
@@ -501,26 +501,24 @@ XPIDL_COMPILE 	= $(CYGWIN_WRAPPER) $(LIB
 XPIDL_LINK	= $(CYGWIN_WRAPPER) $(LIBXUL_DIST)/bin/xpt_link$(BIN_SUFFIX)
 endif
 
 # Java macros
 JAVA_GEN_DIR  = _javagen
 JAVA_DIST_DIR = $(DEPTH)/$(JAVA_GEN_DIR)
 JAVA_IFACES_PKG_NAME = org/mozilla/interfaces
 
-REQ_INCLUDES	= -I$(srcdir) -I. $(foreach d,$(REQUIRES),-I$(DIST)/include/$d) -I$(DIST)/include 
-ifdef LIBXUL_SDK
-REQ_INCLUDES_SDK = $(foreach d,$(REQUIRES),-I$(LIBXUL_SDK)/include/$d) -I$(LIBXUL_SDK)/include
-endif
-
-INCLUDES	= $(LOCAL_INCLUDES) $(REQ_INCLUDES) $(REQ_INCLUDES_SDK) -I$(PUBLIC) $(OS_INCLUDES)
-
-ifndef MOZILLA_INTERNAL_API
-INCLUDES	+= -I$(LIBXUL_DIST)/sdk/include
-endif
+INCLUDES = \
+  $(LOCAL_INCLUDES) \
+  -I$(srcdir) \
+  -I. \
+  -I$(DIST)/include -I$(DIST)/include/nsprpub \
+  $(if $(LIBXUL_SDK),-I$(LIBXUL_SDK)/include -I$(LIBXUL_SDK)/include/nsprpub) \
+  $(OS_INCLUDES) \
+  $(NULL) 
 
 include $(topsrcdir)/config/static-checking-config.mk
 
 ifdef MOZ_SHARK
 OS_CFLAGS += -F/System/Library/PrivateFrameworks
 OS_CXXFLAGS += -F/System/Library/PrivateFrameworks
 OS_LDFLAGS += -F/System/Library/PrivateFrameworks -framework CHUD
 endif # ifdef MOZ_SHARK
@@ -621,32 +619,22 @@ LIBS_DIR	= -L$(DIST)/bin -L$(DIST)/lib
 ifdef LIBXUL_SDK
 LIBS_DIR	+= -L$(LIBXUL_SDK)/bin -L$(LIBXUL_SDK)/lib
 endif
 endif
 endif
 
 # Default location of include files
 IDL_DIR		= $(DIST)/idl
-ifdef MODULE
-PUBLIC		= $(DIST)/include/$(MODULE)
-else
-PUBLIC		= $(DIST)/include
-endif
 
 XPIDL_FLAGS = -I$(srcdir) -I$(IDL_DIR)
 ifdef LIBXUL_SDK
 XPIDL_FLAGS += -I$(LIBXUL_SDK)/idl
 endif
 
-SDK_PUBLIC  = $(DIST)/sdk/include
-SDK_IDL_DIR = $(DIST)/sdk/idl
-SDK_LIB_DIR = $(DIST)/sdk/lib
-SDK_BIN_DIR = $(DIST)/sdk/bin
-
 DEPENDENCIES	= .md
 
 MOZ_COMPONENT_LIBS=$(XPCOM_LIBS) $(MOZ_COMPONENT_NSPR_LIBS)
 
 ifdef GC_LEAK_DETECTOR
 XPCOM_LIBS += -lboehm
 endif
 
--- a/config/nspr/Makefile.in
+++ b/config/nspr/Makefile.in
@@ -54,17 +54,17 @@ endif
 ifdef MOZ_NATIVE_NSPR
 $(error config/nspr/Makefile.in is not compatible with MOZ_NATIVE_NSPR)
 endif
 
 # Copy NSPR to the SDK
 ABS_DIST = $(call core_abspath,$(DIST))
 
 libs::
-	$(MAKE) -C $(DEPTH)/nsprpub install prefix=$(ABS_DIST)/sdk exec_prefix=$(ABS_DIST)/sdk bindir=$(ABS_DIST)/sdk/dummy includedir=$(ABS_DIST)/sdk/include libdir=$(ABS_DIST)/sdk/lib datadir=$(ABS_DIST)/sdk/dummy DESTDIR=
+	$(MAKE) -C $(DEPTH)/nsprpub install prefix=$(ABS_DIST)/sdk exec_prefix=$(ABS_DIST)/sdk bindir=$(ABS_DIST)/sdk/dummy includedir=$(ABS_DIST)/include libdir=$(ABS_DIST)/sdk/lib datadir=$(ABS_DIST)/sdk/dummy DESTDIR=
 	$(RM) -rf $(DIST)/sdk/dummy
 ifneq (,$(filter OS2 WINNT,$(OS_ARCH))) # {
 	$(RM) -f $(DIST)/sdk/lib/$(DLL_PREFIX)nspr4$(DLL_SUFFIX) $(DIST)/sdk/lib/$(DLL_PREFIX)plc4$(DLL_SUFFIX) $(DIST)/sdk/lib/$(DLL_PREFIX)plds4$(DLL_SUFFIX)
 	$(RM) -f $(DIST)/sdk/lib/$(LIB_PREFIX)nspr4_s.$(LIB_SUFFIX) $(DIST)/sdk/lib/$(LIB_PREFIX)plc4_s.$(LIB_SUFFIX) $(DIST)/sdk/lib/$(LIB_PREFIX)plds4_s.$(LIB_SUFFIX)
 else # } {
 	$(RM) -f $(DIST)/sdk/lib/$(LIB_PREFIX)nspr4.$(LIB_SUFFIX) $(DIST)/sdk/lib/$(LIB_PREFIX)plc4.$(LIB_SUFFIX) $(DIST)/sdk/lib/$(LIB_PREFIX)plds4.$(LIB_SUFFIX)
 endif # }
 
--- a/config/rules.mk
+++ b/config/rules.mk
@@ -33,32 +33,40 @@
 # under the terms of either the GPL or the LGPL, and not to allow others to
 # use your version of this file under the terms of the MPL, indicate your
 # decision by deleting the provisions above and replace them with the notice
 # and other provisions required by the GPL or the LGPL. If you do not delete
 # the provisions above, a recipient may use your version of this file under
 # the terms of any one of the MPL, the GPL or the LGPL.
 #
 # ***** END LICENSE BLOCK *****
+
 ifndef topsrcdir
-topsrcdir		= $(DEPTH)
+$(error topsrcdir was not set))
 endif
 
 ifndef MOZILLA_DIR
 MOZILLA_DIR = $(topsrcdir)
 endif
 
 ifndef INCLUDED_CONFIG_MK
 include $(topsrcdir)/config/config.mk
 endif
 
 ifndef INCLUDED_VERSION_MK
 include $(topsrcdir)/config/version.mk
 endif
 
+ifdef SDK_XPIDLSRCS
+XPIDLSRCS += $(SDK_XPIDLSRCS)
+endif
+ifdef SDK_HEADERS
+EXPORTS += $(SDK_HEADERS)
+endif
+
 REPORT_BUILD = @echo $(notdir $<)
 
 ifeq ($(OS_ARCH),OS2)
 EXEC			=
 else
 EXEC			= exec
 endif
 
@@ -190,17 +198,17 @@ endif # XPCSHELL_TESTS
 
 ifdef CPP_UNIT_TESTS
 
 # Compile the tests to $(DIST)/bin.  Make lots of niceties available by default
 # through TestHarness.h, by modifying the list of includes and the libs against
 # which stuff links.
 CPPSRCS += $(CPP_UNIT_TESTS)
 SIMPLE_PROGRAMS += $(CPP_UNIT_TESTS:.cpp=$(BIN_SUFFIX))
-REQUIRES += testing xpcom
+INCLUDES += -I$(DIST)/include/testing
 LIBS += $(XPCOM_GLUE_LDOPTS) $(NSPR_LIBS)
 
 # ...and run them the usual way
 check::
 	@$(EXIT_ON_ERROR) \
 	  for f in $(subst .cpp,,$(CPP_UNIT_TESTS)); do \
 	    XPCOM_DEBUG_BREAK=stack-and-abort $(RUN_TEST_PROGRAM) $(DIST)/bin/$$f; \
 	  done
@@ -380,21 +388,20 @@ ifndef HOST_OBJS
 	$(addprefix host_,$(HOST_CMMSRCS:.mm=.$(OBJ_SUFFIX)))
 HOST_OBJS = $(strip $(_HOST_OBJS))
 endif
 
 LIBOBJS			:= $(addprefix \", $(OBJS))
 LIBOBJS			:= $(addsuffix \", $(LIBOBJS))
 
 ifndef MOZ_AUTO_DEPS
-ifneq (,$(OBJS)$(XPIDLSRCS)$(SDK_XPIDLSRCS)$(SIMPLE_PROGRAMS))
+ifneq (,$(OBJS)$(XPIDLSRCS)$(SIMPLE_PROGRAMS))
 MDDEPFILES		= $(addprefix $(MDDEPDIR)/,$(OBJS:.$(OBJ_SUFFIX)=.pp))
 ifndef NO_GEN_XPT
-MDDEPFILES		+= $(addprefix $(MDDEPDIR)/,$(XPIDLSRCS:.idl=.xpt)) \
-			   $(addprefix $(MDDEPDIR)/,$(SDK_XPIDLSRCS:.idl=.xpt))
+MDDEPFILES		+= $(addprefix $(MDDEPDIR)/,$(XPIDLSRCS:.idl=.xpt))
 endif
 endif
 endif
 
 ALL_TRASH = \
 	$(GARBAGE) $(TARGETS) $(OBJS) $(PROGOBJS) LOGS TAGS a.out \
 	$(filter-out $(ASFILES),$(OBJS:.$(OBJ_SUFFIX)=.s)) $(OBJS:.$(OBJ_SUFFIX)=.ii) \
 	$(OBJS:.$(OBJ_SUFFIX)=.i) \
@@ -501,17 +508,17 @@ endif
 
 ifndef HOST_PROGOBJS
 HOST_PROGOBJS		= $(HOST_OBJS)
 endif
 
 # MAKE_DIRS: List of directories to build while looping over directories.
 # A Makefile that needs $(MDDEPDIR) created but doesn't set any of these
 # variables we know to check can just set NEED_MDDEPDIR explicitly.
-ifneq (,$(OBJS)$(XPIDLSRCS)$(SDK_XPIDLSRCS)$(SIMPLE_PROGRAMS)$(NEED_MDDEPDIR))
+ifneq (,$(OBJS)$(XPIDLSRCS)$(SIMPLE_PROGRAMS)$(NEED_MDDEPDIR))
 MAKE_DIRS		+= $(CURDIR)/$(MDDEPDIR)
 GARBAGE_DIRS		+= $(MDDEPDIR)
 endif
 
 #
 # Tags: emacs (etags), vi (ctags)
 # TAG_PROGRAM := ctags -L -
 #
@@ -780,17 +787,17 @@ endif
 
 ifdef PARALLEL_DIRS
 export:: $(PARALLEL_DIRS_export)
 
 $(PARALLEL_DIRS_export): %_export: %/Makefile
 	+@$(call SUBMAKE,export,$*)
 endif
 
-export:: $(SUBMAKEFILES) $(MAKE_DIRS) $(if $(EXPORTS)$(XPIDLSRCS)$(SDK_HEADERS)$(SDK_XPIDLSRCS),$(PUBLIC)) $(if $(SDK_HEADERS)$(SDK_XPIDLSRCS),$(SDK_PUBLIC)) $(if $(XPIDLSRCS),$(IDL_DIR)) $(if $(SDK_XPIDLSRCS),$(SDK_IDL_DIR))
+export:: $(SUBMAKEFILES) $(MAKE_DIRS) $(if $(XPIDLSRCS),$(IDL_DIR))
 	$(LOOP_OVER_DIRS)
 	$(LOOP_OVER_TOOL_DIRS)
 
 ifdef PARALLEL_DIRS
 tools:: $(PARALLEL_DIRS_tools)
 
 $(PARALLEL_DIRS_tools): %_tools: %/Makefile
 	+@$(call SUBMAKE,tools,$*)
@@ -1546,50 +1553,45 @@ ifdef AUTOUPDATE_CONFIGURE
 	(cd $(topsrcdir) && $(AUTOCONF)) && (cd $(DEPTH) && ./config.status --recheck)
 endif
 
 ###############################################################################
 # Bunch of things that extend the 'export' rule (in order):
 ###############################################################################
 
 ################################################################################
-# Copy each element of EXPORTS to $(PUBLIC)
-
-ifneq ($(EXPORTS)$(XPIDLSRCS)$(SDK_HEADERS)$(SDK_XPIDLSRCS),)
-$(SDK_PUBLIC) $(PUBLIC):
-	$(NSINSTALL) -D $@
-endif
+# Copy each element of EXPORTS to $(DIST)/include
 
 ifdef MOZ_JAVAXPCOM
-ifneq ($(XPIDLSRCS)$(SDK_XPIDLSRCS),)
+ifneq ($(XPIDLSRCS),)
 $(JAVA_DIST_DIR)::
 	$(NSINSTALL) -D $@
 endif
 endif
 
 ifneq ($(XPI_NAME),)
 $(FINAL_TARGET):
 	$(NSINSTALL) -D $@
 
 export:: $(FINAL_TARGET)
 endif
 
 ifndef NO_DIST_INSTALL
-ifneq ($(EXPORTS),)
-export:: $(EXPORTS) $(PUBLIC)
-	$(INSTALL) $(IFLAGS1) $^
-endif 
+
+ifneq (,$(EXPORTS))
+export:: $(EXPORTS)
+	$(INSTALL) $(IFLAGS1) $^ $(DIST)/include
+endif
 
-ifneq ($(SDK_HEADERS),)
-export:: $(SDK_HEADERS) $(SDK_PUBLIC)
-	$(INSTALL) $(IFLAGS1) $^
+define EXPORT_NAMESPACE_RULE
+export:: $(EXPORTS_$(namespace))
+	$(INSTALL) $(IFLAGS1) $$^ $(DIST)/include/$(namespace)
+endef
 
-export:: $(SDK_HEADERS) $(PUBLIC)
-	$(INSTALL) $(IFLAGS1) $^
-endif 
+$(foreach namespace,$(EXPORTS_NAMESPACES),$(eval $(EXPORT_NAMESPACE_RULE)))
 endif # NO_DIST_INSTALL
 
 ################################################################################
 # Copy each element of PREF_JS_EXPORTS
 
 ifdef GRE_MODULE
 PREF_DIR = greprefs
 else
@@ -1629,85 +1631,85 @@ ifneq ($(AUTOCFG_JS_EXPORTS),)
 
 ifndef NO_DIST_INSTALL
 export:: $(AUTOCFG_JS_EXPORTS) $(FINAL_TARGET)/defaults/autoconfig
 	$(INSTALL) $(IFLAGS1) $^
 endif
 
 endif 
 ################################################################################
-# Export the elements of $(XPIDLSRCS) & $(SDK_XPIDLSRCS), 
+# Export the elements of $(XPIDLSRCS)
 # generating .h and .xpt files and moving them to the appropriate places.
 
-ifneq ($(XPIDLSRCS)$(SDK_XPIDLSRCS),)
+ifneq ($(XPIDLSRCS),)
 
 export:: $(patsubst %.idl,$(XPIDL_GEN_DIR)/%.h, $(XPIDLSRCS))
 
 ifndef XPIDL_MODULE
 XPIDL_MODULE		= $(MODULE)
 endif
 
 ifeq ($(XPIDL_MODULE),) # we need $(XPIDL_MODULE) to make $(XPIDL_MODULE).xpt
 export:: FORCE
 	@echo
 	@echo "*** Error processing XPIDLSRCS:"
 	@echo "Please define MODULE or XPIDL_MODULE when defining XPIDLSRCS,"
 	@echo "so we have a module name to use when creating MODULE.xpt."
 	@echo; sleep 2; false
 endif
 
-$(SDK_IDL_DIR) $(IDL_DIR)::
+$(IDL_DIR)::
 	$(NSINSTALL) -D $@
 
-# generate .h files from into $(XPIDL_GEN_DIR), then export to $(PUBLIC);
+# generate .h files from into $(XPIDL_GEN_DIR), then export to $(DIST)/include;
 # warn against overriding existing .h file. 
 $(XPIDL_GEN_DIR)/.done:
 	@if test ! -d $(XPIDL_GEN_DIR); then echo Creating $(XPIDL_GEN_DIR)/.done; rm -rf $(XPIDL_GEN_DIR); mkdir $(XPIDL_GEN_DIR); fi
 	@touch $@
 
 # don't depend on $(XPIDL_GEN_DIR), because the modification date changes
 # with any addition to the directory, regenerating all .h files -> everything.
 
 $(XPIDL_GEN_DIR)/%.h: %.idl $(XPIDL_COMPILE) $(XPIDL_GEN_DIR)/.done
 	$(REPORT_BUILD)
 	$(ELOG) $(XPIDL_COMPILE) -m header -w $(XPIDL_FLAGS) -o $(XPIDL_GEN_DIR)/$* $(_VPATH_SRCS)
-	@if test -n "$(findstring $*.h, $(EXPORTS) $(SDK_HEADERS))"; \
+	@if test -n "$(findstring $*.h, $(EXPORTS))"; \
 	  then echo "*** WARNING: file $*.h generated from $*.idl overrides $(srcdir)/$*.h"; else true; fi
 
 ifndef NO_GEN_XPT
 # generate intermediate .xpt files into $(XPIDL_GEN_DIR), then link
 # into $(XPIDL_MODULE).xpt and export it to $(FINAL_TARGET)/components.
 $(XPIDL_GEN_DIR)/%.xpt: %.idl $(XPIDL_COMPILE) $(XPIDL_GEN_DIR)/.done
 	$(REPORT_BUILD)
 	$(ELOG) $(XPIDL_COMPILE) -m typelib -w $(XPIDL_FLAGS) -e $@ -d $(MDDEPDIR)/$*.pp $(_VPATH_SRCS)
 
 # no need to link together if XPIDLSRCS contains only XPIDL_MODULE
 ifneq ($(XPIDL_MODULE).idl,$(strip $(XPIDLSRCS)))
-$(XPIDL_GEN_DIR)/$(XPIDL_MODULE).xpt: $(patsubst %.idl,$(XPIDL_GEN_DIR)/%.xpt,$(XPIDLSRCS) $(SDK_XPIDLSRCS)) $(GLOBAL_DEPS) $(XPIDL_LINK)
-	$(XPIDL_LINK) $(XPIDL_GEN_DIR)/$(XPIDL_MODULE).xpt $(patsubst %.idl,$(XPIDL_GEN_DIR)/%.xpt,$(XPIDLSRCS) $(SDK_XPIDLSRCS)) 
+$(XPIDL_GEN_DIR)/$(XPIDL_MODULE).xpt: $(patsubst %.idl,$(XPIDL_GEN_DIR)/%.xpt,$(XPIDLSRCS)) $(GLOBAL_DEPS) $(XPIDL_LINK)
+	$(XPIDL_LINK) $(XPIDL_GEN_DIR)/$(XPIDL_MODULE).xpt $(patsubst %.idl,$(XPIDL_GEN_DIR)/%.xpt,$(XPIDLSRCS))
 endif # XPIDL_MODULE.xpt != XPIDLSRCS
 
 libs:: $(XPIDL_GEN_DIR)/$(XPIDL_MODULE).xpt
 ifndef NO_DIST_INSTALL
 	$(INSTALL) $(IFLAGS1) $(XPIDL_GEN_DIR)/$(XPIDL_MODULE).xpt $(FINAL_TARGET)/components
 endif
 
 endif # NO_GEN_XPT
 
 GARBAGE_DIRS		+= $(XPIDL_GEN_DIR)
 
-endif # XPIDLSRCS || SDK_XPIDLSRCS
+endif # XPIDLSRCS
 
 ifneq ($(XPIDLSRCS),)
 # export .idl files to $(IDL_DIR)
 ifndef NO_DIST_INSTALL
 export:: $(XPIDLSRCS) $(IDL_DIR)
 	$(INSTALL) $(IFLAGS1) $^
 
-export:: $(patsubst %.idl,$(XPIDL_GEN_DIR)/%.h, $(XPIDLSRCS)) $(PUBLIC)
+export:: $(patsubst %.idl,$(XPIDL_GEN_DIR)/%.h, $(XPIDLSRCS)) $(DIST)/include
 	$(INSTALL) $(IFLAGS1) $^ 
 endif # NO_DIST_INSTALL
 
 endif # XPIDLSRCS
 
 
 
 #
@@ -1717,53 +1719,30 @@ endif # XPIDLSRCS
 # Bug to fix idl dependency problems w/o this extra build pass is
 #   http://bugzilla.mozilla.org/show_bug.cgi?id=145777
 #
 $(IDL_DIR)::
 	$(NSINSTALL) -D $@
 
 export-idl:: $(SUBMAKEFILES) $(MAKE_DIRS)
 
-ifneq ($(XPIDLSRCS)$(SDK_XPIDLSRCS),)
+ifneq ($(XPIDLSRCS),)
 ifndef NO_DIST_INSTALL
-export-idl:: $(XPIDLSRCS) $(SDK_XPIDLSRCS) $(IDL_DIR)
+export-idl:: $(XPIDLSRCS) $(IDL_DIR)
 	$(INSTALL) $(IFLAGS1) $^
 endif
 endif
 	$(LOOP_OVER_PARALLEL_DIRS)
 	$(LOOP_OVER_DIRS)
 	$(LOOP_OVER_TOOL_DIRS)
 
-
-
-
-ifneq ($(SDK_XPIDLSRCS),)
-# export .idl files to $(IDL_DIR) & $(SDK_IDL_DIR)
-ifndef NO_DIST_INSTALL
-export:: $(SDK_XPIDLSRCS) $(IDL_DIR)
-	$(INSTALL) $(IFLAGS1) $^
-
-export:: $(SDK_XPIDLSRCS) $(SDK_IDL_DIR)
-	$(INSTALL) $(IFLAGS1) $^
+ifdef MOZ_JAVAXPCOM
+ifneq ($(XPIDLSRCS),)
 
-export:: $(patsubst %.idl,$(XPIDL_GEN_DIR)/%.h, $(SDK_XPIDLSRCS)) $(PUBLIC)
-	$(INSTALL) $(IFLAGS1) $^
-
-export:: $(patsubst %.idl,$(XPIDL_GEN_DIR)/%.h, $(SDK_XPIDLSRCS)) $(SDK_PUBLIC)
-	$(INSTALL) $(IFLAGS1) $^
-endif
-
-endif # SDK_XPIDLSRCS
-
-
-
-ifdef MOZ_JAVAXPCOM
-ifneq ($(XPIDLSRCS)$(SDK_XPIDLSRCS),)
-
-JAVA_XPIDLSRCS = $(XPIDLSRCS) $(SDK_XPIDLSRCS)
+JAVA_XPIDLSRCS = $(XPIDLSRCS)
 
 # A single IDL file can contain multiple interfaces, which result in multiple
 # Java interface files.  So use hidden dependency files.
 JAVADEPFILES = $(addprefix $(JAVA_GEN_DIR)/.,$(JAVA_XPIDLSRCS:.idl=.java.pp))
 
 $(JAVA_GEN_DIR):
 	$(NSINSTALL) -D $@
 GARBAGE_DIRS += $(JAVA_GEN_DIR)
@@ -1787,17 +1766,17 @@ JAVA_INSTALL_DIR = $(JAVA_DIST_DIR)/defa
 endif
 
 $(JAVA_INSTALL_DIR):
 	$(NSINSTALL) -D $@
 
 export:: $(JAVA_DIST_DIR) $(JAVADEPFILES) $(JAVA_INSTALL_DIR)
 	(cd $(JAVA_GEN_DIR) && tar $(TAR_CREATE_FLAGS) - .) | (cd $(JAVA_INSTALL_DIR) && tar -xf -)
 
-endif # XPIDLSRCS || SDK_XPIDLSRCS
+endif # XPIDLSRCS
 endif # MOZ_JAVAXPCOM
 
 ################################################################################
 # Copy each element of EXTRA_COMPONENTS to $(FINAL_TARGET)/components
 ifdef EXTRA_COMPONENTS
 libs:: $(EXTRA_COMPONENTS)
 ifndef NO_DIST_INSTALL
 	$(INSTALL) $(IFLAGS1) $^ $(FINAL_TARGET)/components
@@ -1839,41 +1818,16 @@ ifndef NO_DIST_INSTALL
 	  $(RM) -f $$dest; \
 	  $(PYTHON) $(topsrcdir)/config/Preprocessor.py $(DEFINES) $(ACDEFINES) $(XULPPFLAGS) $$i > $$dest; \
 	done
 endif
 
 endif
 
 ################################################################################
-# SDK
-
-ifneq (,$(SDK_LIBRARY))
-$(SDK_LIB_DIR)::
-	$(NSINSTALL) -D $@
-
-ifndef NO_DIST_INSTALL
-libs:: $(SDK_LIBRARY) $(SDK_LIB_DIR)
-	$(INSTALL) $(IFLAGS2) $^
-endif
-
-endif # SDK_LIBRARY
-
-ifneq (,$(SDK_BINARY))
-$(SDK_BIN_DIR)::
-	$(NSINSTALL) -D $@
-
-ifndef NO_DIST_INSTALL
-libs:: $(SDK_BINARY) $(SDK_BIN_DIR)
-	$(INSTALL) $(IFLAGS2) $^
-endif
-
-endif # SDK_BINARY
-
-################################################################################
 # CHROME PACKAGING
 
 JAR_MANIFEST := $(srcdir)/jar.mn
 
 chrome::
 	$(MAKE) realchrome
 	$(LOOP_OVER_PARALLEL_DIRS)
 	$(LOOP_OVER_DIRS)
@@ -2017,17 +1971,17 @@ endef
 $(MDDEPDIR)/%.pp: %.cpp
 	$(REPORT_BUILD)
 	@$(MAKE_DEPS_NOAUTO)
 
 $(MDDEPDIR)/%.pp: %.s
 	$(REPORT_BUILD)
 	@$(MAKE_DEPS_NOAUTO)
 
-ifneq (,$(OBJS)$(XPIDLSRCS)$(SDK_XPIDLSRCS)$(SIMPLE_PROGRAMS))
+ifneq (,$(OBJS)$(XPIDLSRCS)$(SIMPLE_PROGRAMS))
 depend:: $(SUBMAKEFILES) $(MAKE_DIRS) $(MDDEPFILES)
 else
 depend:: $(SUBMAKEFILES)
 endif
 	$(LOOP_OVER_PARALLEL_DIRS)
 	$(LOOP_OVER_DIRS)
 	$(LOOP_OVER_TOOL_DIRS)
 
@@ -2053,17 +2007,17 @@ endif # COMPILER_DEPEND
 #   a previous build in the source tree) and thus neglect to create a
 #   dependency directory in the object directory, where we really need
 #   it.
 
 $(CURDIR)/$(MDDEPDIR):
 	@if test ! -d $@; then echo Creating $@; rm -rf $@; mkdir $@; else true; fi
 
 ifneq (,$(filter-out all chrome default export realchrome tools clean clobber clobber_all distclean realclean,$(MAKECMDGOALS)))
-ifneq (,$(OBJS)$(XPIDLSRCS)$(SDK_XPIDLSRCS)$(SIMPLE_PROGRAMS))
+ifneq (,$(OBJS)$(XPIDLSRCS)$(SIMPLE_PROGRAMS))
 MDDEPEND_FILES		:= $(strip $(wildcard $(MDDEPDIR)/*.pp))
 
 ifneq (,$(MDDEPEND_FILES))
 ifdef PERL
 # The script mddepend.pl checks the dependencies and writes to stdout
 # one rule to force out-of-date objects. For example,
 #   foo.o boo.o: FORCE
 # The script has an advantage over including the *.pp files directly
@@ -2261,8 +2215,30 @@ documentation:
 	$(DOXYGEN) $(DEPTH)/config/doxygen.cfg
 
 ifdef ENABLE_TESTS
 check:: $(SUBMAKEFILES) $(MAKE_DIRS)
 	$(LOOP_OVER_PARALLEL_DIRS)
 	$(LOOP_OVER_DIRS)
 	$(LOOP_OVER_TOOL_DIRS)
 endif
+
+
+FREEZE_VARIABLES = \
+  CSRCS \
+  CPPSRCS \
+  EXPORTS \
+  XPIDLSRCS \
+  DIRS \
+  LIBRARY \
+  MODULE \
+  REQUIRES \
+  SHORT_LIBNAME \
+  TIERS \
+  $(NULL)
+
+$(foreach var,$(FREEZE_VARIABLES),$(eval $(var)_FROZEN := '$($(var))'))
+
+CHECK_FROZEN_VARIABLES = $(foreach var,$(FREEZE_VARIABLES), \
+  $(if $(subst $($(var)_FROZEN),,'$($(var))'),$(error Makefile variable '$(var)' changed value after including rules.mk. Was $($(var)_FROZEN), now $($(var)).)))
+
+libs export libs::
+	$(CHECK_FROZEN_VARIABLES)
--- a/content/media/video/public/nsMediaDecoder.h
+++ b/content/media/video/public/nsMediaDecoder.h
@@ -33,24 +33,24 @@
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 #if !defined(nsMediaDecoder_h_)
 #define nsMediaDecoder_h_
 
-#include "nsIObserver.h"
+#include "mozilla/XPCOM.h"
+
 #include "nsIPrincipal.h"
 #include "nsSize.h"
 #include "prlog.h"
 #include "gfxContext.h"
 #include "gfxRect.h"
 #include "nsITimer.h"
-#include "nsTimeStamp.h"
 
 #ifdef PR_LOGGING
 extern PRLogModuleInfo* gVideoDecoderLog;
 #define LOG(type, msg) PR_LOG(gVideoDecoderLog, type, msg)
 #else
 #define LOG(type, msg)
 #endif
 
--- a/content/media/video/public/nsMediaStream.h
+++ b/content/media/video/public/nsMediaStream.h
@@ -33,27 +33,25 @@
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #if !defined(nsMediaStream_h_)
 #define nsMediaStream_h_
 
-#include "nsCOMPtr.h"
-#include "nsAutoPtr.h"
+#include "mozilla/XPCOM.h"
 #include "nsIChannel.h"
 #include "nsIPrincipal.h"
 #include "nsIURI.h"
 #include "nsIStreamListener.h"
 #include "nsIChannelEventSink.h"
 #include "nsIInterfaceRequestor.h"
 #include "prlock.h"
 #include "nsMediaCache.h"
-#include "nsTimeStamp.h"
 
 // For HTTP seeking, if number of bytes needing to be
 // seeked forward is less than this value then a read is
 // done rather than a byte range request.
 #define SEEK_VS_READ_THRESHOLD (32*1024)
 
 class nsMediaDecoder;
 
--- a/content/media/video/src/nsMediaCache.cpp
+++ b/content/media/video/src/nsMediaCache.cpp
@@ -31,28 +31,29 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
+#include "mozilla/XPCOM.h"
+
 #include "nsMediaCache.h"
 #include "nsAutoLock.h"
 #include "nsContentUtils.h"
 #include "nsDirectoryServiceUtils.h"
 #include "nsDirectoryServiceDefs.h"
 #include "nsNetUtil.h"
 #include "prio.h"
 #include "nsThreadUtils.h"
 #include "nsMediaStream.h"
 #include "nsMathUtils.h"
 #include "prlog.h"
-#include "nsTimeStamp.h"
 
 #ifdef PR_LOGGING
 PRLogModuleInfo* gMediaCacheLog;
 #define LOG(type, msg) PR_LOG(gMediaCacheLog, type, msg)
 #else
 #define LOG(type, msg)
 #endif
 
--- a/embedding/components/printingui/src/mac/printpde/Makefile.in
+++ b/embedding/components/printingui/src/mac/printpde/Makefile.in
@@ -35,32 +35,33 @@
 # ***** END LICENSE BLOCK *****
 
 DEPTH       = ../../../../../..
 topsrcdir	= @top_srcdir@
 srcdir		= @srcdir@
 VPATH		= @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
+
+MODULE       = printpde
+
 include $(topsrcdir)/config/rules.mk
 
 ifdef MOZ_DEBUG
 BUILDSTYLE	= Development
 else
 BUILDSTYLE	= Deployment
 endif
 
 # pbbuild or xcodebuild indicates Xcode; the Xcode project contains
 # native targets needed for proper SDK builds.
 PROJECT=PrintPDE.xcode
 PROJECT_ARG=-project $(PROJECT)
 PBBUILD_ARG=$(PBBUILD_SETTINGS)
 
-MODULE       = printpde
-
 unexport CC CXX
 
 ABS_topsrcdir   := $(shell cd $(topsrcdir); pwd)
 ifneq ($(ABS_topsrcdir),$(MOZ_BUILD_ROOT))
 export::
 	rsync -a --exclude .DS_Store --exclude "CVS/" $(srcdir)/$(PROJECT) .
 	ln -fs $(srcdir)/src
 	ln -fs $(srcdir)/res
--- a/gfx/cairo/cairo/src/Makefile.in
+++ b/gfx/cairo/cairo/src/Makefile.in
@@ -125,17 +125,19 @@ CSRCS   = \
         cairo-toy-font-face.c \
         cairo-traps.c \
         cairo-unicode.c \
 	cairo-user-font.c \
 	cairo-version.c \
         cairo-wideint.c \
         $(NULL)
 
-EXPORTS = cairo.h cairo-version.h cairo-features.h cairo-platform.h cairo-deprecated.h cairo-rename.h
+EXPORTS_NAMESPACES = cairo
+
+EXPORTS_cairo = cairo.h cairo-version.h cairo-features.h cairo-platform.h cairo-deprecated.h cairo-rename.h
 
 # cairo-type1-subset.c should be here, but it's only supported on freetype platforms
 
 PSPDF_BASE_CSRCS = \
 	cairo-base85-stream.c \
 	cairo-type1-fallback.c \
 	cairo-type3-glyph-surface.c \
 	cairo-truetype-subset.c \
--- a/gfx/src/thebes/Makefile.in
+++ b/gfx/src/thebes/Makefile.in
@@ -139,18 +139,17 @@ EXTRA_DSO_LDOPTS += \
 		$(NULL)
 
 ifdef MOZ_X11
 EXTRA_DSO_LDOPTS += $(XLDFLAGS) $(XLIBS)
 endif
 
 include $(topsrcdir)/config/rules.mk
 
-CXXFLAGS  += $(TK_CFLAGS)
-CFLAGS    += $(TK_CFLAGS)
+CXXFLAGS  += $(TK_CFLAGS) $(MOZ_CAIRO_CFLAGS)
 
 ifdef MOZ_ENABLE_GTK2
 DEFINES += -DMOZ_ENABLE_GTK2
 CXXFLAGS += $(MOZ_PANGO_CFLAGS)
 endif
 
 ifeq ($(MOZ_WIDGET_TOOLKIT),os2)
 CXXFLAGS += $(CAIRO_FT_CFLAGS)
--- a/js/src/config/config.mk
+++ b/js/src/config/config.mk
@@ -501,26 +501,24 @@ XPIDL_COMPILE 	= $(CYGWIN_WRAPPER) $(LIB
 XPIDL_LINK	= $(CYGWIN_WRAPPER) $(LIBXUL_DIST)/bin/xpt_link$(BIN_SUFFIX)
 endif
 
 # Java macros
 JAVA_GEN_DIR  = _javagen
 JAVA_DIST_DIR = $(DEPTH)/$(JAVA_GEN_DIR)
 JAVA_IFACES_PKG_NAME = org/mozilla/interfaces
 
-REQ_INCLUDES	= -I$(srcdir) -I. $(foreach d,$(REQUIRES),-I$(DIST)/include/$d) -I$(DIST)/include 
-ifdef LIBXUL_SDK
-REQ_INCLUDES_SDK = $(foreach d,$(REQUIRES),-I$(LIBXUL_SDK)/include/$d) -I$(LIBXUL_SDK)/include
-endif
-
-INCLUDES	= $(LOCAL_INCLUDES) $(REQ_INCLUDES) $(REQ_INCLUDES_SDK) -I$(PUBLIC) $(OS_INCLUDES)
-
-ifndef MOZILLA_INTERNAL_API
-INCLUDES	+= -I$(LIBXUL_DIST)/sdk/include
-endif
+INCLUDES = \
+  $(LOCAL_INCLUDES) \
+  -I$(srcdir) \
+  -I. \
+  -I$(DIST)/include -I$(DIST)/include/nsprpub \
+  $(if $(LIBXUL_SDK),-I$(LIBXUL_SDK)/include -I$(LIBXUL_SDK)/include/nsprpub) \
+  $(OS_INCLUDES) \
+  $(NULL) 
 
 include $(topsrcdir)/config/static-checking-config.mk
 
 ifdef MOZ_SHARK
 OS_CFLAGS += -F/System/Library/PrivateFrameworks
 OS_CXXFLAGS += -F/System/Library/PrivateFrameworks
 OS_LDFLAGS += -F/System/Library/PrivateFrameworks -framework CHUD
 endif # ifdef MOZ_SHARK
@@ -621,32 +619,22 @@ LIBS_DIR	= -L$(DIST)/bin -L$(DIST)/lib
 ifdef LIBXUL_SDK
 LIBS_DIR	+= -L$(LIBXUL_SDK)/bin -L$(LIBXUL_SDK)/lib
 endif
 endif
 endif
 
 # Default location of include files
 IDL_DIR		= $(DIST)/idl
-ifdef MODULE
-PUBLIC		= $(DIST)/include/$(MODULE)
-else
-PUBLIC		= $(DIST)/include
-endif
 
 XPIDL_FLAGS = -I$(srcdir) -I$(IDL_DIR)
 ifdef LIBXUL_SDK
 XPIDL_FLAGS += -I$(LIBXUL_SDK)/idl
 endif
 
-SDK_PUBLIC  = $(DIST)/sdk/include
-SDK_IDL_DIR = $(DIST)/sdk/idl
-SDK_LIB_DIR = $(DIST)/sdk/lib
-SDK_BIN_DIR = $(DIST)/sdk/bin
-
 DEPENDENCIES	= .md
 
 MOZ_COMPONENT_LIBS=$(XPCOM_LIBS) $(MOZ_COMPONENT_NSPR_LIBS)
 
 ifdef GC_LEAK_DETECTOR
 XPCOM_LIBS += -lboehm
 endif
 
--- a/js/src/config/rules.mk
+++ b/js/src/config/rules.mk
@@ -33,32 +33,40 @@
 # under the terms of either the GPL or the LGPL, and not to allow others to
 # use your version of this file under the terms of the MPL, indicate your
 # decision by deleting the provisions above and replace them with the notice
 # and other provisions required by the GPL or the LGPL. If you do not delete
 # the provisions above, a recipient may use your version of this file under
 # the terms of any one of the MPL, the GPL or the LGPL.
 #
 # ***** END LICENSE BLOCK *****
+
 ifndef topsrcdir
-topsrcdir		= $(DEPTH)
+$(error topsrcdir was not set))
 endif
 
 ifndef MOZILLA_DIR
 MOZILLA_DIR = $(topsrcdir)
 endif
 
 ifndef INCLUDED_CONFIG_MK
 include $(topsrcdir)/config/config.mk
 endif
 
 ifndef INCLUDED_VERSION_MK
 include $(topsrcdir)/config/version.mk
 endif
 
+ifdef SDK_XPIDLSRCS
+XPIDLSRCS += $(SDK_XPIDLSRCS)
+endif
+ifdef SDK_HEADERS
+EXPORTS += $(SDK_HEADERS)
+endif
+
 REPORT_BUILD = @echo $(notdir $<)
 
 ifeq ($(OS_ARCH),OS2)
 EXEC			=
 else
 EXEC			= exec
 endif
 
@@ -190,17 +198,17 @@ endif # XPCSHELL_TESTS
 
 ifdef CPP_UNIT_TESTS
 
 # Compile the tests to $(DIST)/bin.  Make lots of niceties available by default
 # through TestHarness.h, by modifying the list of includes and the libs against
 # which stuff links.
 CPPSRCS += $(CPP_UNIT_TESTS)
 SIMPLE_PROGRAMS += $(CPP_UNIT_TESTS:.cpp=$(BIN_SUFFIX))
-REQUIRES += testing xpcom
+INCLUDES += -I$(DIST)/include/testing
 LIBS += $(XPCOM_GLUE_LDOPTS) $(NSPR_LIBS)
 
 # ...and run them the usual way
 check::
 	@$(EXIT_ON_ERROR) \
 	  for f in $(subst .cpp,,$(CPP_UNIT_TESTS)); do \
 	    XPCOM_DEBUG_BREAK=stack-and-abort $(RUN_TEST_PROGRAM) $(DIST)/bin/$$f; \
 	  done
@@ -380,21 +388,20 @@ ifndef HOST_OBJS
 	$(addprefix host_,$(HOST_CMMSRCS:.mm=.$(OBJ_SUFFIX)))
 HOST_OBJS = $(strip $(_HOST_OBJS))
 endif
 
 LIBOBJS			:= $(addprefix \", $(OBJS))
 LIBOBJS			:= $(addsuffix \", $(LIBOBJS))
 
 ifndef MOZ_AUTO_DEPS
-ifneq (,$(OBJS)$(XPIDLSRCS)$(SDK_XPIDLSRCS)$(SIMPLE_PROGRAMS))
+ifneq (,$(OBJS)$(XPIDLSRCS)$(SIMPLE_PROGRAMS))
 MDDEPFILES		= $(addprefix $(MDDEPDIR)/,$(OBJS:.$(OBJ_SUFFIX)=.pp))
 ifndef NO_GEN_XPT
-MDDEPFILES		+= $(addprefix $(MDDEPDIR)/,$(XPIDLSRCS:.idl=.xpt)) \
-			   $(addprefix $(MDDEPDIR)/,$(SDK_XPIDLSRCS:.idl=.xpt))
+MDDEPFILES		+= $(addprefix $(MDDEPDIR)/,$(XPIDLSRCS:.idl=.xpt))
 endif
 endif
 endif
 
 ALL_TRASH = \
 	$(GARBAGE) $(TARGETS) $(OBJS) $(PROGOBJS) LOGS TAGS a.out \
 	$(filter-out $(ASFILES),$(OBJS:.$(OBJ_SUFFIX)=.s)) $(OBJS:.$(OBJ_SUFFIX)=.ii) \
 	$(OBJS:.$(OBJ_SUFFIX)=.i) \
@@ -501,17 +508,17 @@ endif
 
 ifndef HOST_PROGOBJS
 HOST_PROGOBJS		= $(HOST_OBJS)
 endif
 
 # MAKE_DIRS: List of directories to build while looping over directories.
 # A Makefile that needs $(MDDEPDIR) created but doesn't set any of these
 # variables we know to check can just set NEED_MDDEPDIR explicitly.
-ifneq (,$(OBJS)$(XPIDLSRCS)$(SDK_XPIDLSRCS)$(SIMPLE_PROGRAMS)$(NEED_MDDEPDIR))
+ifneq (,$(OBJS)$(XPIDLSRCS)$(SIMPLE_PROGRAMS)$(NEED_MDDEPDIR))
 MAKE_DIRS		+= $(CURDIR)/$(MDDEPDIR)
 GARBAGE_DIRS		+= $(MDDEPDIR)
 endif
 
 #
 # Tags: emacs (etags), vi (ctags)
 # TAG_PROGRAM := ctags -L -
 #
@@ -780,17 +787,17 @@ endif
 
 ifdef PARALLEL_DIRS
 export:: $(PARALLEL_DIRS_export)
 
 $(PARALLEL_DIRS_export): %_export: %/Makefile
 	+@$(call SUBMAKE,export,$*)
 endif
 
-export:: $(SUBMAKEFILES) $(MAKE_DIRS) $(if $(EXPORTS)$(XPIDLSRCS)$(SDK_HEADERS)$(SDK_XPIDLSRCS),$(PUBLIC)) $(if $(SDK_HEADERS)$(SDK_XPIDLSRCS),$(SDK_PUBLIC)) $(if $(XPIDLSRCS),$(IDL_DIR)) $(if $(SDK_XPIDLSRCS),$(SDK_IDL_DIR))
+export:: $(SUBMAKEFILES) $(MAKE_DIRS) $(if $(XPIDLSRCS),$(IDL_DIR))
 	$(LOOP_OVER_DIRS)
 	$(LOOP_OVER_TOOL_DIRS)
 
 ifdef PARALLEL_DIRS
 tools:: $(PARALLEL_DIRS_tools)
 
 $(PARALLEL_DIRS_tools): %_tools: %/Makefile
 	+@$(call SUBMAKE,tools,$*)
@@ -1546,50 +1553,45 @@ ifdef AUTOUPDATE_CONFIGURE
 	(cd $(topsrcdir) && $(AUTOCONF)) && (cd $(DEPTH) && ./config.status --recheck)
 endif
 
 ###############################################################################
 # Bunch of things that extend the 'export' rule (in order):
 ###############################################################################
 
 ################################################################################
-# Copy each element of EXPORTS to $(PUBLIC)
-
-ifneq ($(EXPORTS)$(XPIDLSRCS)$(SDK_HEADERS)$(SDK_XPIDLSRCS),)
-$(SDK_PUBLIC) $(PUBLIC):
-	$(NSINSTALL) -D $@
-endif
+# Copy each element of EXPORTS to $(DIST)/include
 
 ifdef MOZ_JAVAXPCOM
-ifneq ($(XPIDLSRCS)$(SDK_XPIDLSRCS),)
+ifneq ($(XPIDLSRCS),)
 $(JAVA_DIST_DIR)::
 	$(NSINSTALL) -D $@
 endif
 endif
 
 ifneq ($(XPI_NAME),)
 $(FINAL_TARGET):
 	$(NSINSTALL) -D $@
 
 export:: $(FINAL_TARGET)
 endif
 
 ifndef NO_DIST_INSTALL
-ifneq ($(EXPORTS),)
-export:: $(EXPORTS) $(PUBLIC)
-	$(INSTALL) $(IFLAGS1) $^
-endif 
+
+ifneq (,$(EXPORTS))
+export:: $(EXPORTS)
+	$(INSTALL) $(IFLAGS1) $^ $(DIST)/include
+endif
 
-ifneq ($(SDK_HEADERS),)
-export:: $(SDK_HEADERS) $(SDK_PUBLIC)
-	$(INSTALL) $(IFLAGS1) $^
+define EXPORT_NAMESPACE_RULE
+export:: $(EXPORTS_$(namespace))
+	$(INSTALL) $(IFLAGS1) $$^ $(DIST)/include/$(namespace)
+endef
 
-export:: $(SDK_HEADERS) $(PUBLIC)
-	$(INSTALL) $(IFLAGS1) $^
-endif 
+$(foreach namespace,$(EXPORTS_NAMESPACES),$(eval $(EXPORT_NAMESPACE_RULE)))
 endif # NO_DIST_INSTALL
 
 ################################################################################
 # Copy each element of PREF_JS_EXPORTS
 
 ifdef GRE_MODULE
 PREF_DIR = greprefs
 else
@@ -1629,85 +1631,85 @@ ifneq ($(AUTOCFG_JS_EXPORTS),)
 
 ifndef NO_DIST_INSTALL
 export:: $(AUTOCFG_JS_EXPORTS) $(FINAL_TARGET)/defaults/autoconfig
 	$(INSTALL) $(IFLAGS1) $^
 endif
 
 endif 
 ################################################################################
-# Export the elements of $(XPIDLSRCS) & $(SDK_XPIDLSRCS), 
+# Export the elements of $(XPIDLSRCS)
 # generating .h and .xpt files and moving them to the appropriate places.
 
-ifneq ($(XPIDLSRCS)$(SDK_XPIDLSRCS),)
+ifneq ($(XPIDLSRCS),)
 
 export:: $(patsubst %.idl,$(XPIDL_GEN_DIR)/%.h, $(XPIDLSRCS))
 
 ifndef XPIDL_MODULE
 XPIDL_MODULE		= $(MODULE)
 endif
 
 ifeq ($(XPIDL_MODULE),) # we need $(XPIDL_MODULE) to make $(XPIDL_MODULE).xpt
 export:: FORCE
 	@echo
 	@echo "*** Error processing XPIDLSRCS:"
 	@echo "Please define MODULE or XPIDL_MODULE when defining XPIDLSRCS,"
 	@echo "so we have a module name to use when creating MODULE.xpt."
 	@echo; sleep 2; false
 endif
 
-$(SDK_IDL_DIR) $(IDL_DIR)::
+$(IDL_DIR)::
 	$(NSINSTALL) -D $@
 
-# generate .h files from into $(XPIDL_GEN_DIR), then export to $(PUBLIC);
+# generate .h files from into $(XPIDL_GEN_DIR), then export to $(DIST)/include;
 # warn against overriding existing .h file. 
 $(XPIDL_GEN_DIR)/.done:
 	@if test ! -d $(XPIDL_GEN_DIR); then echo Creating $(XPIDL_GEN_DIR)/.done; rm -rf $(XPIDL_GEN_DIR); mkdir $(XPIDL_GEN_DIR); fi
 	@touch $@
 
 # don't depend on $(XPIDL_GEN_DIR), because the modification date changes
 # with any addition to the directory, regenerating all .h files -> everything.
 
 $(XPIDL_GEN_DIR)/%.h: %.idl $(XPIDL_COMPILE) $(XPIDL_GEN_DIR)/.done
 	$(REPORT_BUILD)
 	$(ELOG) $(XPIDL_COMPILE) -m header -w $(XPIDL_FLAGS) -o $(XPIDL_GEN_DIR)/$* $(_VPATH_SRCS)
-	@if test -n "$(findstring $*.h, $(EXPORTS) $(SDK_HEADERS))"; \
+	@if test -n "$(findstring $*.h, $(EXPORTS))"; \
 	  then echo "*** WARNING: file $*.h generated from $*.idl overrides $(srcdir)/$*.h"; else true; fi
 
 ifndef NO_GEN_XPT
 # generate intermediate .xpt files into $(XPIDL_GEN_DIR), then link
 # into $(XPIDL_MODULE).xpt and export it to $(FINAL_TARGET)/components.
 $(XPIDL_GEN_DIR)/%.xpt: %.idl $(XPIDL_COMPILE) $(XPIDL_GEN_DIR)/.done
 	$(REPORT_BUILD)
 	$(ELOG) $(XPIDL_COMPILE) -m typelib -w $(XPIDL_FLAGS) -e $@ -d $(MDDEPDIR)/$*.pp $(_VPATH_SRCS)
 
 # no need to link together if XPIDLSRCS contains only XPIDL_MODULE
 ifneq ($(XPIDL_MODULE).idl,$(strip $(XPIDLSRCS)))
-$(XPIDL_GEN_DIR)/$(XPIDL_MODULE).xpt: $(patsubst %.idl,$(XPIDL_GEN_DIR)/%.xpt,$(XPIDLSRCS) $(SDK_XPIDLSRCS)) $(GLOBAL_DEPS) $(XPIDL_LINK)
-	$(XPIDL_LINK) $(XPIDL_GEN_DIR)/$(XPIDL_MODULE).xpt $(patsubst %.idl,$(XPIDL_GEN_DIR)/%.xpt,$(XPIDLSRCS) $(SDK_XPIDLSRCS)) 
+$(XPIDL_GEN_DIR)/$(XPIDL_MODULE).xpt: $(patsubst %.idl,$(XPIDL_GEN_DIR)/%.xpt,$(XPIDLSRCS)) $(GLOBAL_DEPS) $(XPIDL_LINK)
+	$(XPIDL_LINK) $(XPIDL_GEN_DIR)/$(XPIDL_MODULE).xpt $(patsubst %.idl,$(XPIDL_GEN_DIR)/%.xpt,$(XPIDLSRCS))
 endif # XPIDL_MODULE.xpt != XPIDLSRCS
 
 libs:: $(XPIDL_GEN_DIR)/$(XPIDL_MODULE).xpt
 ifndef NO_DIST_INSTALL
 	$(INSTALL) $(IFLAGS1) $(XPIDL_GEN_DIR)/$(XPIDL_MODULE).xpt $(FINAL_TARGET)/components
 endif
 
 endif # NO_GEN_XPT
 
 GARBAGE_DIRS		+= $(XPIDL_GEN_DIR)
 
-endif # XPIDLSRCS || SDK_XPIDLSRCS
+endif # XPIDLSRCS
 
 ifneq ($(XPIDLSRCS),)
 # export .idl files to $(IDL_DIR)
 ifndef NO_DIST_INSTALL
 export:: $(XPIDLSRCS) $(IDL_DIR)
 	$(INSTALL) $(IFLAGS1) $^
 
-export:: $(patsubst %.idl,$(XPIDL_GEN_DIR)/%.h, $(XPIDLSRCS)) $(PUBLIC)
+export:: $(patsubst %.idl,$(XPIDL_GEN_DIR)/%.h, $(XPIDLSRCS)) $(DIST)/include
 	$(INSTALL) $(IFLAGS1) $^ 
 endif # NO_DIST_INSTALL
 
 endif # XPIDLSRCS
 
 
 
 #
@@ -1717,53 +1719,30 @@ endif # XPIDLSRCS
 # Bug to fix idl dependency problems w/o this extra build pass is
 #   http://bugzilla.mozilla.org/show_bug.cgi?id=145777
 #
 $(IDL_DIR)::
 	$(NSINSTALL) -D $@
 
 export-idl:: $(SUBMAKEFILES) $(MAKE_DIRS)
 
-ifneq ($(XPIDLSRCS)$(SDK_XPIDLSRCS),)
+ifneq ($(XPIDLSRCS),)
 ifndef NO_DIST_INSTALL
-export-idl:: $(XPIDLSRCS) $(SDK_XPIDLSRCS) $(IDL_DIR)
+export-idl:: $(XPIDLSRCS) $(IDL_DIR)
 	$(INSTALL) $(IFLAGS1) $^
 endif
 endif
 	$(LOOP_OVER_PARALLEL_DIRS)
 	$(LOOP_OVER_DIRS)
 	$(LOOP_OVER_TOOL_DIRS)
 
-
-
-
-ifneq ($(SDK_XPIDLSRCS),)
-# export .idl files to $(IDL_DIR) & $(SDK_IDL_DIR)
-ifndef NO_DIST_INSTALL
-export:: $(SDK_XPIDLSRCS) $(IDL_DIR)
-	$(INSTALL) $(IFLAGS1) $^
-
-export:: $(SDK_XPIDLSRCS) $(SDK_IDL_DIR)
-	$(INSTALL) $(IFLAGS1) $^
+ifdef MOZ_JAVAXPCOM
+ifneq ($(XPIDLSRCS),)
 
-export:: $(patsubst %.idl,$(XPIDL_GEN_DIR)/%.h, $(SDK_XPIDLSRCS)) $(PUBLIC)
-	$(INSTALL) $(IFLAGS1) $^
-
-export:: $(patsubst %.idl,$(XPIDL_GEN_DIR)/%.h, $(SDK_XPIDLSRCS)) $(SDK_PUBLIC)
-	$(INSTALL) $(IFLAGS1) $^
-endif
-
-endif # SDK_XPIDLSRCS
-
-
-
-ifdef MOZ_JAVAXPCOM
-ifneq ($(XPIDLSRCS)$(SDK_XPIDLSRCS),)
-
-JAVA_XPIDLSRCS = $(XPIDLSRCS) $(SDK_XPIDLSRCS)
+JAVA_XPIDLSRCS = $(XPIDLSRCS)
 
 # A single IDL file can contain multiple interfaces, which result in multiple
 # Java interface files.  So use hidden dependency files.
 JAVADEPFILES = $(addprefix $(JAVA_GEN_DIR)/.,$(JAVA_XPIDLSRCS:.idl=.java.pp))
 
 $(JAVA_GEN_DIR):
 	$(NSINSTALL) -D $@
 GARBAGE_DIRS += $(JAVA_GEN_DIR)
@@ -1787,17 +1766,17 @@ JAVA_INSTALL_DIR = $(JAVA_DIST_DIR)/defa
 endif
 
 $(JAVA_INSTALL_DIR):
 	$(NSINSTALL) -D $@
 
 export:: $(JAVA_DIST_DIR) $(JAVADEPFILES) $(JAVA_INSTALL_DIR)
 	(cd $(JAVA_GEN_DIR) && tar $(TAR_CREATE_FLAGS) - .) | (cd $(JAVA_INSTALL_DIR) && tar -xf -)
 
-endif # XPIDLSRCS || SDK_XPIDLSRCS
+endif # XPIDLSRCS
 endif # MOZ_JAVAXPCOM
 
 ################################################################################
 # Copy each element of EXTRA_COMPONENTS to $(FINAL_TARGET)/components
 ifdef EXTRA_COMPONENTS
 libs:: $(EXTRA_COMPONENTS)
 ifndef NO_DIST_INSTALL
 	$(INSTALL) $(IFLAGS1) $^ $(FINAL_TARGET)/components
@@ -1839,41 +1818,16 @@ ifndef NO_DIST_INSTALL
 	  $(RM) -f $$dest; \
 	  $(PYTHON) $(topsrcdir)/config/Preprocessor.py $(DEFINES) $(ACDEFINES) $(XULPPFLAGS) $$i > $$dest; \
 	done
 endif
 
 endif
 
 ################################################################################
-# SDK
-
-ifneq (,$(SDK_LIBRARY))
-$(SDK_LIB_DIR)::
-	$(NSINSTALL) -D $@
-
-ifndef NO_DIST_INSTALL
-libs:: $(SDK_LIBRARY) $(SDK_LIB_DIR)
-	$(INSTALL) $(IFLAGS2) $^
-endif
-
-endif # SDK_LIBRARY
-
-ifneq (,$(SDK_BINARY))
-$(SDK_BIN_DIR)::
-	$(NSINSTALL) -D $@
-
-ifndef NO_DIST_INSTALL
-libs:: $(SDK_BINARY) $(SDK_BIN_DIR)
-	$(INSTALL) $(IFLAGS2) $^
-endif
-
-endif # SDK_BINARY
-
-################################################################################
 # CHROME PACKAGING
 
 JAR_MANIFEST := $(srcdir)/jar.mn
 
 chrome::
 	$(MAKE) realchrome
 	$(LOOP_OVER_PARALLEL_DIRS)
 	$(LOOP_OVER_DIRS)
@@ -2017,17 +1971,17 @@ endef
 $(MDDEPDIR)/%.pp: %.cpp
 	$(REPORT_BUILD)
 	@$(MAKE_DEPS_NOAUTO)
 
 $(MDDEPDIR)/%.pp: %.s
 	$(REPORT_BUILD)
 	@$(MAKE_DEPS_NOAUTO)
 
-ifneq (,$(OBJS)$(XPIDLSRCS)$(SDK_XPIDLSRCS)$(SIMPLE_PROGRAMS))
+ifneq (,$(OBJS)$(XPIDLSRCS)$(SIMPLE_PROGRAMS))
 depend:: $(SUBMAKEFILES) $(MAKE_DIRS) $(MDDEPFILES)
 else
 depend:: $(SUBMAKEFILES)
 endif
 	$(LOOP_OVER_PARALLEL_DIRS)
 	$(LOOP_OVER_DIRS)
 	$(LOOP_OVER_TOOL_DIRS)
 
@@ -2053,17 +2007,17 @@ endif # COMPILER_DEPEND
 #   a previous build in the source tree) and thus neglect to create a
 #   dependency directory in the object directory, where we really need
 #   it.
 
 $(CURDIR)/$(MDDEPDIR):
 	@if test ! -d $@; then echo Creating $@; rm -rf $@; mkdir $@; else true; fi
 
 ifneq (,$(filter-out all chrome default export realchrome tools clean clobber clobber_all distclean realclean,$(MAKECMDGOALS)))
-ifneq (,$(OBJS)$(XPIDLSRCS)$(SDK_XPIDLSRCS)$(SIMPLE_PROGRAMS))
+ifneq (,$(OBJS)$(XPIDLSRCS)$(SIMPLE_PROGRAMS))
 MDDEPEND_FILES		:= $(strip $(wildcard $(MDDEPDIR)/*.pp))
 
 ifneq (,$(MDDEPEND_FILES))
 ifdef PERL
 # The script mddepend.pl checks the dependencies and writes to stdout
 # one rule to force out-of-date objects. For example,
 #   foo.o boo.o: FORCE
 # The script has an advantage over including the *.pp files directly
@@ -2261,8 +2215,30 @@ documentation:
 	$(DOXYGEN) $(DEPTH)/config/doxygen.cfg
 
 ifdef ENABLE_TESTS
 check:: $(SUBMAKEFILES) $(MAKE_DIRS)
 	$(LOOP_OVER_PARALLEL_DIRS)
 	$(LOOP_OVER_DIRS)
 	$(LOOP_OVER_TOOL_DIRS)
 endif
+
+
+FREEZE_VARIABLES = \
+  CSRCS \
+  CPPSRCS \
+  EXPORTS \
+  XPIDLSRCS \
+  DIRS \
+  LIBRARY \
+  MODULE \
+  REQUIRES \
+  SHORT_LIBNAME \
+  TIERS \
+  $(NULL)
+
+$(foreach var,$(FREEZE_VARIABLES),$(eval $(var)_FROZEN := '$($(var))'))
+
+CHECK_FROZEN_VARIABLES = $(foreach var,$(FREEZE_VARIABLES), \
+  $(if $(subst $($(var)_FROZEN),,'$($(var))'),$(error Makefile variable '$(var)' changed value after including rules.mk. Was $($(var)_FROZEN), now $($(var)).)))
+
+libs export libs::
+	$(CHECK_FROZEN_VARIABLES)
--- a/media/libfishsound/include/fishsound/Makefile.in
+++ b/media/libfishsound/include/fishsound/Makefile.in
@@ -36,19 +36,19 @@
 
 DEPTH		= ../../../..
 topsrcdir	= @top_srcdir@
 srcdir		= @srcdir@
 VPATH		= @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
-MODULE		= fishsound
+EXPORTS_NAMESPACES = fishsound
 
-EXPORTS		= \
+EXPORTS_fishsound = \
 		comments.h \
 		constants.h \
 		decode.h \
 		deprecated.h \
 		encode.h \
 		fishsound.h \
 		$(NULL)
 
--- a/media/libogg/include/ogg/Makefile.in
+++ b/media/libogg/include/ogg/Makefile.in
@@ -36,17 +36,17 @@
 
 DEPTH		= ../../../..
 topsrcdir	= @top_srcdir@
 srcdir		= @srcdir@
 VPATH		= @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
-MODULE		= ogg
+EXPORTS_NAMESPACES = ogg
 
-EXPORTS		= \
-		ogg.h \
-		config_types.h \
-		os_types.h \
-		$(NULL)
+EXPORTS_ogg = \
+  ogg.h \
+  config_types.h \
+  os_types.h \
+  $(NULL)
 
 include $(topsrcdir)/config/rules.mk
--- a/media/liboggplay/include/oggplay/Makefile.in
+++ b/media/liboggplay/include/oggplay/Makefile.in
@@ -36,22 +36,22 @@
 
 DEPTH		= ../../../..
 topsrcdir	= @top_srcdir@
 srcdir		= @srcdir@
 VPATH		= @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
-MODULE		= oggplay
+EXPORTS_NAMESPACES = oggplay
 
-EXPORTS		= \
-		config_win32.h \
-		oggplay.h \
-		oggplay_callback_info.h \
-		oggplay_enums.h \
-		oggplay_reader.h \
-		oggplay_tools.h \
-		oggplay_seek.h \
-		oggplay_query.h \
-		$(NULL)
+EXPORTS_oggplay = \
+  config_win32.h \
+  oggplay.h \
+  oggplay_callback_info.h \
+  oggplay_enums.h \
+  oggplay_reader.h \
+  oggplay_tools.h \
+  oggplay_seek.h \
+  oggplay_query.h \
+  $(NULL)
 
 include $(topsrcdir)/config/rules.mk
--- a/media/liboggplay/src/liboggplay/Makefile.in
+++ b/media/liboggplay/src/liboggplay/Makefile.in
@@ -43,29 +43,29 @@ include $(DEPTH)/config/autoconf.mk
 
 DEFINES += -DHAVE_CONFIG_H
 
 MODULE		= oggplay
 LIBRARY_NAME	= oggplay
 FORCE_STATIC_LIB= 1
 
 EXPORTS		= \
-		oggplay_private.h \
 		oggplay_buffer.h \
 		oggplay_callback.h \
 		oggplay_data.h \
-		oggplay_private.h \
 		std_semaphore.h \
 		$(NULL)
 
 CSRCS		= \
 		oggplay.c \
 		oggplay_callback.c \
 		oggplay_query.c \
 		oggplay_data.c \
 		oggplay_callback_info.c \
 		oggplay_buffer.c \
 		oggplay_seek.c \
 		oggplay_yuv2rgb.c \
 		oggplay_tools.c \
 		$(NULL)
 
 include $(topsrcdir)/config/rules.mk
+
+LOCAL_INCLUDES += -I$(srcdir)/../../include/oggplay
--- a/media/liboggz/include/oggz/Makefile.in
+++ b/media/liboggz/include/oggz/Makefile.in
@@ -36,21 +36,19 @@
 
 DEPTH		= ../../../..
 topsrcdir	= @top_srcdir@
 srcdir		= @srcdir@
 VPATH		= @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
-MODULE		= oggz
+EXPORTS_NAMESPACES = oggz
 
-EXPORTS		= \
-		config.h \
-		config_win32.h \
+EXPORTS_oggz = \
 		oggz.h \
 		oggz_comments.h \
 		oggz_constants.h \
 		oggz_deprecated.h \
 		oggz_io.h \
 		oggz_off_t.h \
 		oggz_off_t_generated.h \
 		oggz_read.h \
--- a/media/liboggz/src/liboggz/Makefile.in
+++ b/media/liboggz/src/liboggz/Makefile.in
@@ -57,8 +57,10 @@ CSRCS		= \
 		oggz_seek.c \
 		oggz_stream.c \
 		oggz_table.c \
 		oggz_vector.c \
 		oggz_write.c \
 		$(NULL)
 
 include $(topsrcdir)/config/rules.mk
+
+LOCAL_INCLUDES += -I$(srcdir)/../../include/oggz
--- a/media/libsydneyaudio/include/Makefile.in
+++ b/media/libsydneyaudio/include/Makefile.in
@@ -36,15 +36,15 @@
 
 DEPTH		= ../../..
 topsrcdir	= @top_srcdir@
 srcdir		= @srcdir@
 VPATH		= @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
-MODULE		= sydneyaudio
+EXPORTS_NAMESPACES = sydneyaudio
 
-EXPORTS		= \
+EXPORTS_sydneyaudio = \
 		sydney_audio.h \
 		$(NULL)
 
 include $(topsrcdir)/config/rules.mk
--- a/media/libsydneyaudio/src/Makefile.in
+++ b/media/libsydneyaudio/src/Makefile.in
@@ -71,8 +71,10 @@ CSRCS		= \
 		$(NULL)
 endif
 
 ifeq ($(OS_ARCH),WINNT)
 OS_LIBS += winmm.lib
 endif
 
 include $(topsrcdir)/config/rules.mk
+
+LOCAL_INCLUDES += -I$(srcdir)/../include
--- a/media/libtheora/include/theora/Makefile.in
+++ b/media/libtheora/include/theora/Makefile.in
@@ -36,17 +36,17 @@
 
 DEPTH		= ../../../..
 topsrcdir	= @top_srcdir@
 srcdir		= @srcdir@
 VPATH		= @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
-MODULE		= theora
+EXPORTS_NAMESPACES = theora
 
-EXPORTS		= \
+EXPORTS_theora = \
 		theora.h \
 		theoradec.h \
 		codec.h \
 		$(NULL)
 
 include $(topsrcdir)/config/rules.mk
--- a/media/libvorbis/include/vorbis/Makefile.in
+++ b/media/libvorbis/include/vorbis/Makefile.in
@@ -36,15 +36,12 @@
 
 DEPTH		= ../../../..
 topsrcdir	= @top_srcdir@
 srcdir		= @srcdir@
 VPATH		= @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
-MODULE		= vorbis
-
-EXPORTS		= \
-		codec.h \
-		$(NULL)
+EXPORTS_NAMESPACES = vorbis
+EXPORTS_vorbis = codec.h
 
 include $(topsrcdir)/config/rules.mk
--- a/modules/plugin/default/mac/DefaultPlugin.xcodeproj/project.pbxproj
+++ b/modules/plugin/default/mac/DefaultPlugin.xcodeproj/project.pbxproj
@@ -160,64 +160,64 @@
 			isa = XCBuildConfiguration;
 			buildSettings = {
 				ALWAYS_SEARCH_USER_PATHS = NO;
 				COPY_PHASE_STRIP = NO;
 				GCC_DYNAMIC_NO_PIC = NO;
 				GCC_ENABLE_FIX_AND_CONTINUE = YES;
 				GCC_MODEL_TUNING = G5;
 				GCC_OPTIMIZATION_LEVEL = 0;
-				HEADER_SEARCH_PATHS = ../../../../dist/include/plugin;
+				HEADER_SEARCH_PATHS = ../../../../dist/include;
 				INFOPLIST_FILE = Info.plist;
 				INSTALL_PATH = "$(HOME)/Library/Bundles";
 				PRODUCT_NAME = DefaultPlugin;
 				WRAPPER_EXTENSION = plugin;
 			};
 			name = Debug;
 		};
 		1DEB911C08733D790010E9CD /* Release */ = {
 			isa = XCBuildConfiguration;
 			buildSettings = {
 				ALWAYS_SEARCH_USER_PATHS = NO;
 				DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
 				GCC_MODEL_TUNING = G5;
-				HEADER_SEARCH_PATHS = ../../../../dist/include/plugin;
+				HEADER_SEARCH_PATHS = ../../../../dist/include;
 				INFOPLIST_FILE = Info.plist;
 				INSTALL_PATH = "$(HOME)/Library/Bundles";
 				PRODUCT_NAME = DefaultPlugin;
 				WRAPPER_EXTENSION = plugin;
 			};
 			name = Release;
 		};
 		1DEB911F08733D790010E9CD /* Debug */ = {
 			isa = XCBuildConfiguration;
 			buildSettings = {
 				ARCHS = "$(ARCHS_STANDARD_32_BIT)";
 				GCC_C_LANGUAGE_STANDARD = c99;
 				GCC_OPTIMIZATION_LEVEL = 0;
 				GCC_PREPROCESSOR_DEFINITIONS = "XP_MACOSX=1";
 				GCC_WARN_ABOUT_RETURN_TYPE = YES;
 				GCC_WARN_UNUSED_VARIABLE = YES;
-				HEADER_SEARCH_PATHS = ../../../../dist/include/plugin;
+				HEADER_SEARCH_PATHS = ../../../../dist/include;
 				ONLY_ACTIVE_ARCH = YES;
 				PREBINDING = NO;
 				SDKROOT = "";
 				WRAPPER_EXTENSION = plugin;
 			};
 			name = Debug;
 		};
 		1DEB912008733D790010E9CD /* Release */ = {
 			isa = XCBuildConfiguration;
 			buildSettings = {
 				ARCHS = "$(ARCHS_STANDARD_32_BIT)";
 				GCC_C_LANGUAGE_STANDARD = c99;
 				GCC_PREPROCESSOR_DEFINITIONS = "XP_MACOSX=1";
 				GCC_WARN_ABOUT_RETURN_TYPE = YES;
 				GCC_WARN_UNUSED_VARIABLE = YES;
-				HEADER_SEARCH_PATHS = ../../../../dist/include/plugin;
+				HEADER_SEARCH_PATHS = ../../../../dist/include;
 				PREBINDING = NO;
 				SDKROOT = "";
 				SEPARATE_SYMBOL_EDIT = NO;
 				STRIP_INSTALLED_PRODUCT = YES;
 				WRAPPER_EXTENSION = plugin;
 			};
 			name = Release;
 		};
--- a/modules/plugin/default/mac/Makefile.in
+++ b/modules/plugin/default/mac/Makefile.in
@@ -36,19 +36,19 @@
 # ***** END LICENSE BLOCK *****
 
 DEPTH		= ../../../..
 topsrcdir	= @top_srcdir@
 srcdir		= @srcdir@
 VPATH		= @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
-include $(topsrcdir)/config/rules.mk
+MODULE      = plugin
 
-MODULE      = plugin
+include $(topsrcdir)/config/rules.mk
 
 ifdef MOZ_DEBUG
 BUILDSTYLE	= Debug
 else
 BUILDSTYLE	= Release
 endif
 
 PROJECT=DefaultPlugin.xcodeproj
--- a/modules/zlib/src/Makefile.in
+++ b/modules/zlib/src/Makefile.in
@@ -59,14 +59,14 @@ endif
 endif
 
 ifeq (,$(filter-out WINNT WINCE OS2,$(OS_ARCH)))
 DEFINES	+= -DZLIB_DLL=1
 endif
 
 CSRCS		= $(MODULES_ZLIB_SRC_LCSRCS)
 
-EXPORTS		= $(MODULES_ZLIB_SRC_LEXPORTS)
+EXPORTS		= zlib.h zconf.h mozzconf.h
 
 # This library is used by other shared libs in a static build
 FORCE_USE_PIC = 1
 
 include $(topsrcdir)/config/rules.mk
--- a/modules/zlib/src/objs.mk
+++ b/modules/zlib/src/objs.mk
@@ -45,13 +45,10 @@ MODULES_ZLIB_SRC_LCSRCS = \
 		inffast.c \
 		inflate.c \
 		inftrees.c \
 		trees.c \
 		uncompr.c \
 		zutil.c \
 		$(NULL)
 
-MODULES_ZLIB_SRC_LEXPORTS = zlib.h zconf.h mozzconf.h
+MODULES_ZLIB_SRC_CSRCS := $(addprefix $(topsrcdir)/modules/zlib/src/, $(MODULES_ZLIB_SRC_LCSRCS))
 
-MODULES_ZLIB_SRC_CSRCS := $(addprefix $(topsrcdir)/modules/zlib/src/, $(MODULES_ZLIB_SRC_LCSRCS))
-MODULES_ZLIB_SRC_EXPORTS := $(addprefix $(topsrcdir)/modules/zlib/src/, $(MODULES_ZLIB_SRC_LEXPORTS))
-
--- a/modules/zlib/standalone/Makefile.in
+++ b/modules/zlib/standalone/Makefile.in
@@ -43,17 +43,16 @@ VPATH		= @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 include $(srcdir)/../src/objs.mk
 
 MODULE		= zlib
 LIBRARY_NAME	= mozz_s
 
 CSRCS		= $(MODULES_ZLIB_SRC_LCSRCS)
-EXPORTS		= $(MODULES_ZLIB_SRC_EXPORTS)
 
 FORCE_STATIC_LIB = 1
 SRCS_IN_OBJDIR	= 1
 
 ifeq ($(OS_ARCH),WINNT)
 USE_STATIC_LIBS=1
 endif
 
--- a/security/manager/Makefile.in
+++ b/security/manager/Makefile.in
@@ -357,19 +357,17 @@ endif
 	$(INSTALL) -m 755 $(DIST)/lib/$(FREEBL_64INT_LIB) $(DIST)/bin
 	$(INSTALL) -m 755 $(DIST)/lib/$(FREEBL_64FPU_LIB) $(DIST)/bin
 endif
 endif
 ifndef MOZ_NATIVE_NSS
 # NSS installs headers to dist/public and we want them in dist/include
 	$(NSINSTALL) -D $(DIST)/include/nss
 	(cd $(DIST)/public/nss && tar $(TAR_CREATE_FLAGS) - .) | \
-	  (cd $(DIST)/include/nss && tar -xf -)
-	(cd $(DIST)/public/nss && tar $(TAR_CREATE_FLAGS) - .) | \
-	  (cd $(DIST)/sdk/include && tar -xf -)
+	  (cd $(DIST)/include && tar -xf -)
 endif
 	$(MAKE) -C boot $@
 	$(MAKE) -C ssl $@
 	$(MAKE) -C locales $@
 ifdef MOZ_XUL
 	$(MAKE) -C pki $@
 endif
 
--- a/storage/public/Makefile.in
+++ b/storage/public/Makefile.in
@@ -59,18 +59,18 @@ XPIDLSRCS = \
 	mozIStorageValueArray.idl \
 	mozIStorageResultSet.idl \
 	mozIStorageRow.idl \
   mozIStorageError.idl \
   mozIStorageStatementCallback.idl \
   mozIStoragePendingStatement.idl \
 	$(NULL)
 
+EXPORTS_NAMESPACES = mozilla
+
 EXPORTS = \
 	mozStorageHelper.h \
 	mozStorage.h \
 	$(NULL)
 
-# TODO temp hack until build system handles this
-export:: storage.h
-	$(INSTALL) $^ $(DIST)/include/mozilla/storage
+EXPORTS_mozilla = storage.h
 
 include $(topsrcdir)/config/rules.mk
--- a/storage/src/Makefile.in
+++ b/storage/src/Makefile.in
@@ -56,16 +56,20 @@ LIBXUL_LIBRARY = 1
 REQUIRES = xpcom \
            string \
            sqlite3 \
            js \
            xpconnect \
            necko \
            $(NULL)
 
+EXPORTS_namespaces = mozilla/storage
+
+EXPORTS_mozilla/storage = Variant.h
+
 CPPSRCS = \
   mozStorageService.cpp \
   mozStorageConnection.cpp \
   mozStorageStatement.cpp \
   mozStorageStatementWrapper.cpp \
   mozStorageStatementParams.cpp \
   mozStorageStatementRow.cpp \
   mozStorageArgValueArray.cpp \
@@ -81,13 +85,9 @@ CPPSRCS = \
 
 LOCAL_INCLUDES = \
 	$(SQLITE_CFLAGS)
 
 # This is the default value.  If we ever change it when compiling sqlite, we
 # will need to change it here as well.
 DEFINES += -DSQLITE_MAX_LIKE_PATTERN_LENGTH=50000
 
-# TODO temp hack until build system handles this
-export:: Variant.h
-	$(INSTALL) $^ $(DIST)/include/mozilla/storage
-
 include $(topsrcdir)/config/rules.mk
--- a/toolkit/mozapps/installer/packager.mk
+++ b/toolkit/mozapps/installer/packager.mk
@@ -414,63 +414,51 @@ endif # MOZ_PKG_REMOVALS
 make-package: stage-package $(PACKAGE_XULRUNNER)
 	@echo "Compressing..."
 	$(NSINSTALL) -D $(DIST)/$(PKG_PATH)
 	cd $(DIST) && $(MAKE_PACKAGE)
 
 # The install target will install the application to prefix/lib/appname-version
 # In addition if INSTALL_SDK is set, it will install the development headers,
 # libraries, and IDL files as follows:
-# dist/sdk/include -> prefix/include/appname-version/stable
-# dist/include -> prefix/include/appname-version/unstable
-# dist/sdk/idl -> prefix/share/idl/appname-version/stable
-# dist/idl -> prefix/share/idl/appname-version/unstable
+# dist/include -> prefix/include/appname-version
+# dist/idl -> prefix/share/idl/appname-version
 # dist/sdk/lib -> prefix/lib/appname-devel-version/lib
 # prefix/lib/appname-devel-version/* symlinks to the above directories
 install:: stage-package
 ifneq (,$(filter WINNT,$(OS_ARCH)))
 	$(error "make install" is not supported on this platform. Use "make package" instead.)
 endif
 ifeq (bundle,$(MOZ_FS_LAYOUT))
 	$(error "make install" is not supported on this platform. Use "make package" instead.)
 endif
 	$(NSINSTALL) -D $(DESTDIR)$(installdir)
 	(cd $(DIST)/$(MOZ_PKG_DIR) && tar $(TAR_CREATE_FLAGS) - .) | \
 	  (cd $(DESTDIR)$(installdir) && tar -xf -)
 	$(NSINSTALL) -D $(DESTDIR)$(bindir)
 	$(RM) -f $(DESTDIR)$(bindir)/$(MOZ_APP_NAME)
 	ln -s $(installdir)/$(MOZ_APP_NAME) $(DESTDIR)$(bindir)
 ifdef INSTALL_SDK # Here comes the hard part
-# include directory is stable (dist/sdk/include) and unstable (dist/include)
-	$(NSINSTALL) -D $(DESTDIR)$(includedir)/stable
-	$(NSINSTALL) -D $(DESTDIR)$(includedir)/unstable
-	(cd $(DIST)/sdk/include && tar $(TAR_CREATE_FLAGS) - .) | \
-	  (cd $(DESTDIR)$(includedir)/stable && tar -xf -)
-# The dist/include has module subdirectories that we need to flatten
-	find $(DIST)/include -xtype f -exec $(SYSINSTALL) $(IFLAGS1) {} $(DESTDIR)$(includedir)/unstable \;
-# IDL directory is stable (dist/sdk/idl) and unstable (dist/idl)
-	$(NSINSTALL) -D $(DESTDIR)$(idldir)/stable 
-	$(NSINSTALL) -D $(DESTDIR)$(idldir)/unstable
-	(cd $(DIST)/sdk/idl && tar $(TAR_CREATE_FLAGS) - .) | \
-	  (cd $(DESTDIR)$(idldir)/stable && tar -xf -)
+	$(NSINSTALL) -D $(DESTDIR)$(includedir)
+	(cd $(DIST)/include && tar $(TAR_CREATE_FLAGS) - .) | \
+	  (cd $(DESTDIR)$(includedir) && tar -xf -)
+	$(NSINSTALL) -D $(DESTDIR)$(idldir)
 	(cd $(DIST)/idl && tar $(TAR_CREATE_FLAGS) - .) | \
-	  (cd $(DESTDIR)$(idldir)/unstable && tar -xf -)
+	  (cd $(DESTDIR)$(idldir) && tar -xf -)
 # SDK directory is the libs + a bunch of symlinks
 	$(NSINSTALL) -D $(DESTDIR)$(sdkdir)/sdk/lib
-	if test -f $(DIST)/sdk/include/xpcom-config.h; then \
-	  $(SYSINSTALL) $(IFLAGS1) $(DIST)/sdk/include/xpcom-config.h $(DESTDIR)$(sdkdir); \
+	if test -f $(DIST)/include/xpcom-config.h; then \
+	  $(SYSINSTALL) $(IFLAGS1) $(DIST)/include/xpcom-config.h $(DESTDIR)$(sdkdir); \
 	fi
 	(cd $(DIST)/sdk/lib && tar $(TAR_CREATE_FLAGS) - .) | (cd $(DESTDIR)$(sdkdir)/sdk/lib && tar -xf -)
-	$(RM) -f $(DESTDIR)$(sdkdir)/lib $(DESTDIR)$(sdkdir)/bin $(DESTDIR)$(sdkdir)/sdk/include $(DESTDIR)$(sdkdir)/include $(DESTDIR)$(sdkdir)/sdk/idl $(DESTDIR)$(sdkdir)/idl
+	$(RM) -f $(DESTDIR)$(sdkdir)/lib $(DESTDIR)$(sdkdir)/bin $(DESTDIR)$(sdkdir)/include $(DESTDIR)$(sdkdir)/include $(DESTDIR)$(sdkdir)/sdk/idl $(DESTDIR)$(sdkdir)/idl
 	ln -s $(sdkdir)/sdk/lib $(DESTDIR)$(sdkdir)/lib
 	ln -s $(installdir) $(DESTDIR)$(sdkdir)/bin
-	ln -s $(includedir)/stable $(DESTDIR)$(sdkdir)/sdk/include
-	ln -s $(includedir)/unstable $(DESTDIR)$(sdkdir)/include
-	ln -s $(idldir)/stable $(DESTDIR)$(sdkdir)/sdk/idl
-	ln -s $(idldir)/unstable $(DESTDIR)$(sdkdir)/idl
+	ln -s $(includedir) $(DESTDIR)$(sdkdir)/include
+	ln -s $(idldir) $(DESTDIR)$(sdkdir)/idl
 endif # INSTALL_SDK
 
 make-sdk:
 	$(MAKE) stage-package UNIVERSAL_BINARY= STAGE_SDK=1 MOZ_PKG_DIR=sdk-stage
 	@echo "Packaging SDK..."
 	$(RM) -rf $(DIST)/$(MOZ_APP_NAME)-sdk
 	$(NSINSTALL) -D $(DIST)/$(MOZ_APP_NAME)-sdk/bin
 	(cd $(DIST)/sdk-stage && tar $(TAR_CREATE_FLAGS) - .) | \
--- a/toolkit/mozapps/update/src/updater/Makefile.in
+++ b/toolkit/mozapps/update/src/updater/Makefile.in
@@ -72,16 +72,18 @@ CPPSRCS += \
 	$(NULL)
 OS_LIBS += $(call EXPAND_LIBNAME,comctl32 ws2_32 shell32)
 DEFINES += -DUNICODE -D_UNICODE
 ifndef GNU_CC
 RCFLAGS += -I$(srcdir)
 else
 RCFLAGS += --include-dir $(srcdir)
 endif
+
+REQUIRES += string
 endif
 
 ifneq ($(MOZ_ENABLE_GTK2),)
 HAVE_PROGRESSUI = 1
 CPPSRCS += \
 	progressui_gtk.cpp \
 	$(NULL)
 OS_CXXFLAGS += $(TK_CFLAGS)
@@ -133,12 +135,11 @@ libs::
 	$(NSINSTALL) -D $(DIST)/bin/updater.app/Contents/MacOS
 	$(NSINSTALL) $(DIST)/bin/updater $(DIST)/bin/updater.app/Contents/MacOS
 	rm -f $(DIST)/bin/updater
 endif
 
 ifeq ($(OS_ARCH),WINNT)
 # Pick up nsWindowsRestart.cpp
 LOCAL_INCLUDES += -I$(topsrcdir)/toolkit/xre
-REQUIRES += string
 endif
 
 CXXFLAGS += $(BZ2_CFLAGS)
--- a/widget/src/windows/Makefile.in
+++ b/widget/src/windows/Makefile.in
@@ -140,8 +140,10 @@ ifdef WINCE
 EXTRA_DSO_LDOPTS += ddraw.lib
 endif
 
 ifndef WINCE
 ENABLE_CXX_EXCEPTIONS = 1
 endif
 
 include $(topsrcdir)/config/rules.mk
+
+CXXFLAGS += $(MOZ_CAIRO_CFLAGS)
--- a/xpcom/build/Makefile.in
+++ b/xpcom/build/Makefile.in
@@ -126,24 +126,30 @@ LOCAL_INCLUDES	= \
 		-I$(srcdir)/../io \
 		-I$(srcdir)/../components \
 		-I$(srcdir)/../threads \
 		-I$(srcdir)/../threads/_xpidlgen \
 		-I$(srcdir)/../proxy/src \
 		-I$(srcdir)/../reflect/xptinfo/src \
 		$(NULL)
 
+EXPORTS_NAMESPACES = mozilla
+
 SDK_HEADERS =  \
-		nsXPCOM.h       \
-		nsXPCOMCID.h    \
-		$(NULL)
+  nsXPCOM.h       \
+  nsXPCOMCID.h    \
+  $(NULL)
 
 EXPORTS	= \
-		nsXPCOMCIDInternal.h \
-		$(NULL)
+  nsXPCOMCIDInternal.h \
+  $(NULL)
+
+EXPORTS_mozilla = \
+  XPCOM.h \
+  $(NULL)
 
 # Force use of PIC
 FORCE_USE_PIC	= 1 
 
 ifndef MOZ_ENABLE_LIBXUL
 FORCE_SHARED_LIB = 1
 endif
 
new file mode 100644
--- /dev/null
+++ b/xpcom/build/XPCOM.h
@@ -0,0 +1,198 @@
+#ifndef mozilla_XPCOM_h
+#define mozilla_XPCOM_h
+
+// NOTE: the following headers are sorted topologically, not alphabetically.
+// Do not reorder them without review from bsmedberg.
+
+// system headers required by XPCOM headers
+
+#include <string.h>
+
+// core headers required by pretty much everything else
+
+#include "nscore.h"
+
+#include "nsXPCOMCID.h"
+#include "nsXPCOM.h"
+
+#include "nsError.h"
+#include "nsDebug.h"
+#include "nsMemory.h"
+#include "nsTraceRefcnt.h"
+
+#include "nsID.h"
+
+#include "nsISupports.h"
+
+#include "nsTArray.h"
+#include "nsTPtrArray.h"
+#include "nsTWeakRef.h"
+
+#include "nsCOMPtr.h"
+#include "nsCOMArray.h"
+
+#ifndef MOZILLA_INTERNAL_API
+#include "nsStringAPI.h"
+#else
+#include "nsString.h"
+#include "nsReadableUtils.h"
+#include "nsNativeCharsetUtils.h"
+#endif
+
+#include "nsISupportsUtils.h"
+#include "nsISupportsImpl.h"
+
+// core data structures
+
+#include "nsTHashtable.h"
+#include "nsHashKeys.h"
+#include "nsBaseHashtable.h"
+#include "nsDataHashtable.h"
+#include "nsInterfaceHashtable.h"
+#include "nsClassHashtable.h"
+#include "nsRefPtrHashtable.h"
+#include "mozilla/TimeStamp.h"
+
+// interfaces that inherit directly from nsISupports
+
+#include "nsIArray.h"
+#include "nsIAtom.h"
+#include "nsIAtomService.h"
+#include "nsICategoryManager.h"
+#include "nsIClassInfo.h"
+#include "nsICollection.h"
+#include "nsIComponentManager.h"
+#include "nsIComponentRegistrar.h"
+#include "nsIConsoleListener.h"
+#include "nsIConsoleMessage.h"
+#include "nsIConsoleService.h"
+#include "nsIDebug.h"
+#include "nsIDirectoryEnumerator.h"
+#include "nsIEnumerator.h"
+#include "nsIEnvironment.h"
+#include "nsIErrorService.h"
+#include "nsIEventTarget.h"
+#include "nsIException.h"
+#include "nsIExceptionService.h"
+#include "nsIFactory.h"
+#include "nsIFastLoadFileControl.h"
+#include "nsIFastLoadService.h"
+#include "nsIFile.h"
+#include "nsIHashable.h"
+#include "nsIINIParser.h"
+#include "nsIInputStream.h"
+#include "nsIInterfaceRequestor.h"
+#include "nsILineInputStream.h"
+#include "nsIMemory.h"
+#include "nsIMemoryReporter.h"
+#include "nsIModule.h"
+#include "nsIModuleLoader.h"
+#include "nsIMutable.h"
+#include "nsIObserver.h"
+#include "nsIObserverService.h"
+#include "nsIOutputStream.h"
+#include "nsIProcess.h"
+#include "nsIProgrammingLanguage.h"
+#include "nsIProperties.h"
+#include "nsIPropertyBag2.h"
+#include "nsIRecyclingAllocator.h"
+#include "nsIRunnable.h"
+#include "nsISeekableStream.h"
+#include "nsISerializable.h"
+#include "nsIServiceManager.h"
+#include "nsIScriptableInputStream.h"
+#include "nsISimpleEnumerator.h"
+#include "nsISimpleUnicharStreamFactory.h"
+#include "nsIStreamBufferAccess.h"
+#include "nsIStringEnumerator.h"
+#include "nsIStorageStream.h"
+#include "nsISupportsArray.h"
+#include "nsISupportsIterators.h"
+#include "nsISupportsPrimitives.h"
+#include "nsISupportsPriority.h"
+#include "nsIThreadManager.h"
+#include "nsITimelineService.h"
+#include "nsITimer.h"
+#include "nsITraceRefcnt.h"
+#include "nsIUUIDGenerator.h"
+#include "nsIUnicharInputStream.h"
+#include "nsIUnicharOutputStream.h"
+#include "nsIUnicharLineInputStream.h"
+#include "nsIVariant.h"
+#include "nsIVersionComparator.h"
+#include "nsIWeakReference.h"
+#include "nsIWritablePropertyBag2.h"
+
+// interfaces that include something above
+
+#include "nsIAsyncInputStream.h"
+#include "nsIAsyncOutputStream.h"
+#include "nsIBinaryInputStream.h"
+#include "nsIBinaryOutputStream.h"
+#include "nsIConverterInputStream.h"
+#include "nsIConverterOutputStream.h"
+#include "nsIDebug2.h"
+#include "nsIInputStreamTee.h"
+#include "nsILocalFile.h"
+#include "nsIMultiplexInputStream.h"
+#include "nsIMutableArray.h"
+#include "nsIPersistentProperties2.h"
+#include "nsIStringStream.h"
+#include "nsIThread.h"
+#include "nsIThreadPool.h"
+
+// interfaces that include something above
+
+#include "nsILocalFileWin.h"
+#include "nsIObjectInputStream.h"
+#include "nsIObjectOutputStream.h"
+#include "nsIPipe.h"
+
+#ifdef XP_MACOSX
+#include "nsILocalFileMac.h"
+#include "nsIMacUtils.h"
+#endif
+
+#ifdef XP_OS2
+#include "nsILocalFileOS2.h"
+#endif
+
+// xpcom/glue utility headers
+
+#include "nsComponentManagerUtils.h"
+#include "nsServiceManagerUtils.h"
+
+#include "nsIWeakReferenceUtils.h"
+#include "nsWeakReference.h"
+
+#include "nsArrayEnumerator.h"
+#include "nsArrayUtils.h"
+#include "nsAutoLock.h"
+#include "nsCRTGlue.h"
+#include "nsCycleCollectionParticipant.h"
+#include "nsDeque.h"
+#include "nsEnumeratorUtils.h"
+#include "nsIClassInfoImpl.h"
+#include "nsIGenericFactory.h"
+#include "nsIInterfaceRequestorUtils.h"
+#include "nsINIParser.h"
+#include "nsProxyRelease.h"
+#include "nsTObserverArray.h"
+#include "nsTextFormatter.h"
+#include "nsThreadUtils.h"
+#include "nsVersionComparator.h"
+#include "nsXPTCUtils.h"
+
+// xpcom/base utility headers
+
+#include "nsAgg.h"
+#include "nsAutoRef.h"
+#include "nsInterfaceRequestorAgg.h"
+
+// xpcom/io utility headers
+
+#include "nsAppDirectoryServiceDefs.h"
+#include "nsDirectoryServiceDefs.h"
+#include "nsDirectoryServiceUtils.h"
+
+#endif // mozilla_XPCOM_h
--- a/xpcom/build/nsXPComInit.cpp
+++ b/xpcom/build/nsXPComInit.cpp
@@ -32,28 +32,27 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-#include "nsXPCOM.h"
+#include "mozilla/XPCOM.h"
+
 #include "nsXPCOMPrivate.h"
 #include "nsXPCOMCIDInternal.h"
-#include "nscore.h"
-#include "nsIClassInfoImpl.h"
+
 #include "nsStaticComponents.h"
 #include "prlink.h"
-#include "nsCOMPtr.h"
+
 #include "nsObserverList.h"
 #include "nsObserverService.h"
 #include "nsProperties.h"
-#include "nsIProperties.h"
 #include "nsPersistentProperties.h"
 #include "nsScriptableInputStream.h"
 #include "nsBinaryStream.h"
 #include "nsStorageStream.h"
 #include "nsPipe.h"
 
 #include "nsMemoryImpl.h"
 #include "nsDebugImpl.h"
@@ -80,17 +79,16 @@
 #include "nsProxyEventPrivate.h"  // access to the impl of nsProxyObjectManager for the generic factory registration.
 
 #include "xptinfo.h"
 #include "nsIInterfaceInfoManager.h"
 #include "xptiprivate.h"
 
 #include "nsTimerImpl.h"
 #include "TimerThread.h"
-#include "nsTimeStamp.h"
 
 #include "nsThread.h"
 #include "nsProcess.h"
 #include "nsEnvironment.h"
 #include "nsVersionComparatorImpl.h"
 
 #include "nsILocalFile.h"
 #include "nsLocalFile.h"
@@ -138,18 +136,16 @@ NS_DECL_CLASSINFO(nsStringInputStream)
 #include "nsMacUtilsImpl.h"
 #endif
 
 #include "nsSystemInfo.h"
 #include "nsMemoryReporterManager.h"
 
 #include <locale.h>
 
-#include "nsXPCOM.h"
-
 using mozilla::TimeStamp;
 
 // Registry Factory creation function defined in nsRegistry.cpp
 // We hook into this function locally to create and register the registry
 // Since noone outside xpcom needs to know about this and nsRegistry.cpp
 // does not have a local include file, we are putting this definition
 // here rather than in nsIRegistry.h
 extern nsresult NS_RegistryGetFactory(nsIFactory** aFactory);
--- a/xpcom/ds/Makefile.in
+++ b/xpcom/ds/Makefile.in
@@ -48,16 +48,17 @@ LIBRARY_NAME	= xpcomds_s
 GRE_MODULE	= 1
 MOZILLA_INTERNAL_API = 1
 
 REQUIRES	= \
 		  string \
 		  $(NULL)
 
 CPPSRCS		= \
+		TimeStamp.cpp \
 		nsArray.cpp \
 		nsAtomTable.cpp \
 		nsAtomService.cpp \
 		nsByteBuffer.cpp \
 		nsCheapSets.cpp \
 		nsCRT.cpp \
 		nsFixedSizeAllocator.cpp \
 		nsHashPropertyBag.cpp \
@@ -70,21 +71,26 @@ CPPSRCS		= \
 		nsPersistentProperties.cpp \
 		nsRecyclingAllocator.cpp \
 		nsStaticNameTable.cpp \
 		nsStringEnumerator.cpp \
 		nsSupportsArray.cpp \
 		nsSupportsArrayEnumerator.cpp \
 		nsSupportsPrimitives.cpp \
 		nsTimelineService.cpp \
-		nsTimeStamp.cpp \
 		nsUnicharBuffer.cpp \
 		nsVariant.cpp \
 		$(NULL)
 
+EXPORTS_NAMESPACES = mozilla
+
+EXPORTS_mozilla = \
+  TimeStamp.h \
+  $(NULL)
+
 EXPORTS		= \
 		nsAtomService.h \
 		nsCheapSets.h \
 		nsCppSharedAllocator.h \
 		nsCRT.h \
 		nsDoubleHashtable.h \
 		nsExpirationTracker.h \
 		nsFixedSizeAllocator.h \
@@ -96,17 +102,16 @@ EXPORTS		= \
 		nsMathUtils.h \
 		nsObserverService.h \
 		nsRecyclingAllocator.h \
 		nsStaticNameTable.h \
 		nsStaticAtom.h \
 		nsSupportsArray.h \
 		nsSupportsPrimitives.h \
 		nsTime.h \
-		nsTimeStamp.h \
 		nsVariant.h \
 		nsStringEnumerator.h \
 		nsHashPropertyBag.h \
 		nsWhitespaceTokenizer.h \
 		nsCommaSeparatedTokenizer.h \
 		$(NULL)			
 
 XPIDLSRCS	= \
@@ -142,18 +147,16 @@ SDK_XPIDLSRCS   = \
 		$(NULL)
 
 ifneq (,$(filter WINNT WINCE,$(OS_ARCH)))
 CPPSRCS += nsWindowsRegKey.cpp
 XPIDLSRCS += nsIWindowsRegKey.idl
 EXPORTS += nsWindowsRegKey.h
 endif
 
-EXPORTS		:= $(addprefix $(srcdir)/, $(EXPORTS))
-
 # we don't want the shared lib, but we want to force the creation of a static lib.
 FORCE_STATIC_LIB = 1
 
 # Force use of PIC
 FORCE_USE_PIC	= 1
 
 include $(topsrcdir)/config/rules.mk
 
rename from xpcom/ds/nsTimeStamp.cpp
rename to xpcom/ds/TimeStamp.cpp
--- a/xpcom/ds/nsTimeStamp.cpp
+++ b/xpcom/ds/TimeStamp.cpp
@@ -31,17 +31,17 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-#include "nsTimeStamp.h"
+#include "mozilla/TimeStamp.h"
 #include "prlock.h"
 
 namespace mozilla {
 
 static PRLock* gTimeStampLock;
 static PRUint32 gRolloverCount;
 static PRIntervalTime gLastNow;
 
rename from xpcom/ds/nsTimeStamp.h
rename to xpcom/ds/TimeStamp.h
--- a/xpcom/ds/nsTimeStamp.h
+++ b/xpcom/ds/TimeStamp.h
@@ -31,18 +31,18 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-#ifndef nsTimeStamp_h_
-#define nsTimeStamp_h_
+#ifndef mozilla_TimeStamp_h
+#define mozilla_TimeStamp_h
 
 #include "prinrval.h"
 #include "nsDebug.h"
 
 namespace mozilla {
 
 class TimeStamp;
 
@@ -233,9 +233,9 @@ private:
    * time to wrap around is about 2^64/100000 seconds, i.e. about
    * 5,849,424 years.
    */
   PRUint64 mValue;
 };
 
 }
 
-#endif /* nsTimeStamp_h_ */
+#endif /* mozilla_TimeStamp_h */
--- a/xpcom/glue/Makefile.in
+++ b/xpcom/glue/Makefile.in
@@ -116,32 +116,37 @@ SDK_HEADERS = \
 		nsTextFormatter.h \
 		nsTraceRefcnt.h \
 		nsVersionComparator.h \
 		nsVoidArray.h \
 		nsWeakReference.h \
 		pldhash.h \
 		$(NULL)
 
+EXPORTS_NAMESPACES = mozilla
+
 EXPORTS = \
 		nsThreadUtils.h \
 		nsProxyRelease.h \
 		nsXPTCUtils.h \
 		$(NULL)
 
+EXPORTS_mozilla = \
+  BlockingResourceBase.h \
+  CondVar.h \
+  DeadlockDetector.h \
+  Monitor.h \
+  Mutex.h \
+  $(NULL)
+
 SDK_LIBRARY     =                        \
 		$(LIB_PREFIX)xpcomglue_s.$(LIB_SUFFIX) \
 		$(NULL)
 
 
-## TODO temp hack until build system handles this
-export:: BlockingResourceBase.h CondVar.h DeadlockDetector.h Monitor.h Mutex.h
-	$(INSTALL) $^ $(DIST)/include/mozilla
-
-
 # we don't want the shared lib, but we want to force the creation of a static lib.
 FORCE_STATIC_LIB = 1
 
 # Force use of PIC
 FORCE_USE_PIC	= 1
 
 # Pretend we're statically linking the CRT, even though we might not be: this
 # avoids "msvcrp" and assembly dependencies from creeping into the directives
--- a/xpcom/reflect/xptcall/src/md/unix/Makefile.in
+++ b/xpcom/reflect/xptcall/src/md/unix/Makefile.in
@@ -286,17 +286,17 @@ CXXFLAGS	:= $(shell echo $(CXXFLAGS) | s
 endif
 endif
 endif
 
 ifeq ($(OS_ARCH),Linux)
 ifneq (,$(findstring mips, $(OS_TEST)))
 CPPSRCS		:= xptcinvoke_mips.cpp xptcstubs_mips.cpp
 ASFILES		:= xptcinvoke_asm_mips.s xptcstubs_asm_mips.s
-ASFLAGS		+= -I$(PUBLIC) -x assembler-with-cpp
+ASFLAGS		+= -I$(DIST)/include -x assembler-with-cpp
 endif
 endif
 
 ######################################################################
 # PowerPC
 ######################################################################
 #
 # AIX/PPC
@@ -472,75 +472,75 @@ DEFINES		+= -DEXPORT_XPTC_API -D_IMPL_NS
 
 LOCAL_INCLUDES += \
 	-I$(srcdir)/../.. \
 	-I$(srcdir)/../../../../xptinfo/src \
 	$(NULL)
 
 ifeq ($(OS_ARCH),Linux)
 ifneq (,$(findstring mips, $(OS_TEST)))
-xptcstubs_asm_mips.o: $(PUBLIC)/xptcstubsdef.inc
+xptcstubs_asm_mips.o: $(DIST)/include/xptcstubsdef.inc
 endif
 endif
 
 ifeq ($(OS_ARCH),Darwin)
-xptcstubs_asm_ppc_darwin.o: xptcstubs_asm_ppc_darwin.s.m4 $(PUBLIC)/xptcstubsdef.inc Makefile
+xptcstubs_asm_ppc_darwin.o: xptcstubs_asm_ppc_darwin.s.m4 $(DIST)/include/xptcstubsdef.inc Makefile
 	gm4 $(INCLUDES) $< > ./xptcstubs_asm_ppc_darwin.s && \
 	$(AS) -o $@ $(ASFLAGS) $(AS_DASH_C_FLAG) ./xptcstubs_asm_ppc_darwin.s
 	$(RM) -f ./xptcstubs_asm_ppc_darwin.s
 endif
 
 ifeq ($(OS_ARCH),AIX)
 ifdef HAVE_64BIT_OS
-xptcstubs_asm_ppc_aix64.o: xptcstubs_asm_ppc_aix64.s.m4 $(PUBLIC)/xptcstubsdef.inc Makefile
+xptcstubs_asm_ppc_aix64.o: xptcstubs_asm_ppc_aix64.s.m4 $(DIST)/include/xptcstubsdef.inc Makefile
 	m4 -DAIX_OBJMODEL=$(AIX_OBJMODEL) $(INCLUDES) -I. $< > ./xptcstubs_asm_ppc_aix64.s && \
 	$(AS) -o $@ $(ASFLAGS) $(AS_DASH_C_FLAG) ./xptcstubs_asm_ppc_aix64.s
 	$(RM) ./xptcstubs_asm_ppc_aix64.s
 else
-xptcstubs_asm_ppc_aix.o: xptcstubs_asm_ppc_aix.s.m4 $(PUBLIC)/xptcstubsdef.inc Makefile
+xptcstubs_asm_ppc_aix.o: xptcstubs_asm_ppc_aix.s.m4 $(DIST)/include/xptcstubsdef.inc Makefile
 	m4 -DAIX_OBJMODEL=$(AIX_OBJMODEL) $(INCLUDES) -I. $< > ./xptcstubs_asm_ppc_aix.s && \
 	$(AS) -o $@ $(ASFLAGS) $(AS_DASH_C_FLAG) ./xptcstubs_asm_ppc_aix.s
 	$(RM) ./xptcstubs_asm_ppc_aix.s
 endif
 endif
 
 ifeq ($(OS_ARCH),IRIX)
 # The assembler on IRIX (6.3 only?) seems to have trouble with the default command,
 # but works fine if we first copy the header and source file into the current dir.
-xptcstubs_asm_irix.o: $(PUBLIC)/xptcstubsdef.inc $(srcdir)/xptcstubs_asm_irix.s
+xptcstubs_asm_irix.o: $(DIST)/include/xptcstubsdef.inc $(srcdir)/xptcstubs_asm_irix.s
 	@rm -f ./xptcstubsdef.inc
-	@cp $(PUBLIC)/xptcstubsdef.inc .
+	@cp $(DIST)/include/xptcstubsdef.inc .
 	@if test ! -f ./Makefile.in; then rm -f ./xptcstubs_asm_irix.s; cp $(srcdir)/xptcstubs_asm_irix.s .; else true; fi
 	$(AS) -o $@ $(ASFLAGS) $(AS_DASH_C_FLAG) ./xptcstubs_asm_irix.s
 	@rm -f ./xptcstubsdef.inc
 	@if test ! -f ./Makefile.in; then rm -f ./xptcstubs_asm_irix.s; else true; fi
 endif
 
 ifeq ($(OS_ARCH),OpenVMS)
 # Our assembler wants the include file to be of assembler syntax, not C/C++
 # syntax, so we have to massage it slightly.
 
-xptcstubs_asm_openvms_alpha.o: $(PUBLIC)/xptcstubsdef.inc $(srcdir)/xptcstubs_asm_openvms_alpha.s
+xptcstubs_asm_openvms_alpha.o: $(DIST)/include/xptcstubsdef.inc $(srcdir)/xptcstubs_asm_openvms_alpha.s
 	sed \
 	  -e 's/^\(.*_ENTRY\)(\([0-9]*\))/ \1 \2/' \
 	  -e 's/\/\*\(.*\)\*\//; \1/' \
-	$(PUBLIC)/xptcstubsdef.inc > ./xptcstubsdef_asm.vms
+	$(DIST)/include/xptcstubsdef.inc > ./xptcstubsdef_asm.vms
 	$(AS) -o $@ $(ASFLAGS) $(AS_DASH_C_FLAG) $(srcdir)/xptcstubs_asm_openvms_alpha.s
 	@rm -f ./xptcstubsdef_asm.vms
 endif
 
 ifeq ($(OS_ARCH),SunOS)
 ifeq (86,$(findstring 86,$(OS_TEST)))
 ifndef GNU_CC
-xptcstubs_asm_x86_solaris_SUNW.o: $(PUBLIC)/xptcstubsdef.inc $(srcdir)/xptcstubs_asm_x86_solaris_SUNW.s
+xptcstubs_asm_x86_solaris_SUNW.o: $(DIST)/include/xptcstubsdef.inc $(srcdir)/xptcstubs_asm_x86_solaris_SUNW.s
 	sed \
 	  -e 's/^\(STUB_ENTRY\)(\([0-9]\))/\11\(\2\)/' \
 	  -e 's/^\(STUB_ENTRY\)(\([0-9][0-9]\))/\12\(\2\)/' \
 	  -e 's/^\(STUB_ENTRY\)(\([0-9][0-9][0-9]\))/\13\(\2\)/' \
-	$(PUBLIC)/xptcstubsdef.inc > ./xptcstubsdef_asm.solx86
+	$(DIST)/include/xptcstubsdef.inc > ./xptcstubsdef_asm.solx86
 	$(AS) -o $@ $(ASFLAGS) $(AS_DASH_C_FLAG) -I./ $(srcdir)/xptcstubs_asm_x86_solaris_SUNW.s
 	@rm -f ./xptcstubsdef_asm.solx86
 endif
 endif
 endif
 
 libs:: $(LIBRARY)
 	$(INSTALL) $(LIBRARY) ../..
--- a/xpcom/tests/TestTimeStamp.cpp
+++ b/xpcom/tests/TestTimeStamp.cpp
@@ -30,17 +30,17 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-#include "nsTimeStamp.h"
+#include "mozilla/TimeStamp.h"
 
 #include "TestHarness.h"
 
 #include "prinrval.h"
 #include "prthread.h"
 
 using mozilla::TimeStamp;
 using mozilla::TimeDuration;
--- a/xulrunner/installer/Makefile.in
+++ b/xulrunner/installer/Makefile.in
@@ -80,31 +80,29 @@ install:: $(MOZILLA_VERSION).system.conf
 	$(SYSINSTALL) $(IFLAGS1) $^ $(DESTDIR)$(regdir)
 endif
 
 # Add pkg-config files to the install:: target
 
 pkg_config_files = \
 	libxul.pc \
 	libxul-embedding.pc \
-	libxul-unstable.pc \
-	libxul-embedding-unstable.pc \
 	mozilla-js.pc \
 	mozilla-plugin.pc \
 	mozilla-gtkmozembed.pc \
 	mozilla-gtkmozembed-embedding.pc \
 	$(NULL)
 
 ifdef MOZ_NATIVE_NSPR
 NSPR_NAME=nspr
 NSPR_VERSION=$(shell $(NSPR_CONFIG) --version)
 else
 pkg_config_files += mozilla-nspr.pc
 NSPR_NAME=mozilla-nspr
-FULL_NSPR_CFLAGS=-I\$${includedir}/stable
+FULL_NSPR_CFLAGS=-I\$${includedir}
 FULL_NSPR_LIBS=$(subst $(prefix),\$${sdkdir},$(shell $(DEPTH)/nsprpub/config/nspr-config --libs))
 NSPR_VERSION=$(shell $(DEPTH)/nsprpub/config/nspr-config --version)
 endif
 
 $(warning FULL_NSPR_CFLAGS=$(FULL_NSPR_CFLAGS))
 
 ifndef MOZ_NATIVE_NSS
 pkg_config_files += mozilla-nss.pc
deleted file mode 100644
--- a/xulrunner/installer/libxul-embedding-unstable.pc.in
+++ /dev/null
@@ -1,11 +0,0 @@
-prefix=%prefix%
-sdkdir=%sdkdir%
-includedir=%includedir%
-idldir=%idldir%
-includetype=unstable
-
-Name: libxul-embedding-unstable
-Description: Static library for version-independent embedding of the Mozilla runtime (unstable API)
-Version: %MOZILLA_VERSION%
-Libs: -L${sdkdir}/lib -lxpcomglue
-Cflags: -DXPCOM_GLUE -I${includedir}/${includetype} %WCHAR_CFLAGS%
--- a/xulrunner/installer/libxul-embedding.pc.in
+++ b/xulrunner/installer/libxul-embedding.pc.in
@@ -1,15 +1,10 @@
 prefix=%prefix%
 sdkdir=%sdkdir%
 includedir=%includedir%
 idldir=%idldir%
-includetype=stable
-
-# Note: the default pkg-config cflags will only list include directories
-# that contain stable (frozen or safe for linking) header files. To include
-# nonfrozen headers, run pkg-config with --define-variable=includetype=unstable
 
 Name: libxul-embedding
 Description: Static library for version-independent embedding of the Mozilla runtime
 Version: %MOZILLA_VERSION%
 Libs: -L${sdkdir}/lib -lxpcomglue
-Cflags: -DXPCOM_GLUE -I${includedir}/${includetype} %WCHAR_CFLAGS%
+Cflags: -DXPCOM_GLUE -I${includedir} %WCHAR_CFLAGS%
deleted file mode 100644
--- a/xulrunner/installer/libxul-unstable.pc.in
+++ /dev/null
@@ -1,12 +0,0 @@
-prefix=%prefix%
-sdkdir=%sdkdir%
-includedir=%includedir%
-idldir=%idldir%
-includetype=unstable
-
-Name: libxul
-Description: The Mozilla Runtime and Embedding Engine (unstable API)
-Version: %MOZILLA_VERSION%
-Requires: %NSPR_NAME% >= %NSPR_VERSION%
-Libs: -L${sdkdir}/lib -lxpcomglue_s -lxul -lxpcom
-Cflags: -I${includedir}/${includetype} %WCHAR_CFLAGS%
--- a/xulrunner/installer/libxul.pc.in
+++ b/xulrunner/installer/libxul.pc.in
@@ -1,16 +1,11 @@
 prefix=%prefix%
 sdkdir=%sdkdir%
 includedir=%includedir%
 idldir=%idldir%
-includetype=stable
-
-# Note: the default pkg-config includes will only list include directories
-# that contain stable (frozen or safe for linking) header files. To include
-# nonfrozen headers, run pkg-config with --define-variable=includetype=unstable
 
 Name: libxul
 Description: The Mozilla Runtime and Embedding Engine
 Version: %MOZILLA_VERSION%
 Requires: %NSPR_NAME% >= %NSPR_VERSION%
 Libs: -L${sdkdir}/lib -lxpcomglue_s -lxul -lxpcom
-Cflags: -I${includedir}/${includetype} %WCHAR_CFLAGS%
+Cflags: -I${includedir} %WCHAR_CFLAGS%