--- config/config.mk.orig	2011-08-20 18:12:22.000000000 -0700
+++ config/config.mk	2011-08-20 18:56:24.000000000 -0700
@@ -601,6 +601,12 @@ ifeq (2,$(MOZ_OPTIMIZE))
 PBBUILD_SETTINGS += GCC_MODEL_TUNING= OPTIMIZATION_CFLAGS="$(MOZ_OPTIMIZE_FLAGS)"
 endif # MOZ_OPTIMIZE=2
 endif # MOZ_OPTIMIZE
+# Tell the Darwin linker how to find shared libraries that are not yet installed.
+ifneq (,$(findstring -lplds4,$(EXTRA_DSO_LDOPTS)))
+EXTRA_DSO_LDOPTS += $(foreach library, $(patsubst -l%, $(LIB_PREFIX)%$(DLL_SUFFIX), $(filter -l%, $(NSPR_LIBS))), -dylib_file @executable_path/$(library):$(DIST)/bin/$(library))
+endif
+EXTRA_DSO_LDOPTS += -dylib_file @executable_path/libxul.dylib:$(DIST)/bin/libxul.dylib
+EXTRA_DSO_LDOPTS += -dylib_file @executable_path/libmozjs.dylib:$(DIST)/bin/libmozjs.dylib
 endif # OS_ARCH=Darwin
 
 
