$NetBSD$
---- nsprpub/pr/src/linking/prlink.c.orig 2009-02-03 23:19:38.000000000 +0900
-+++ nsprpub/pr/src/linking/prlink.c
-@@ -155,7 +155,7 @@ struct _imcb *IAC$GL_IMAGE_LIST = NULL;
- /*
- * On these platforms, symbols have a leading '_'.
- */
--#if defined(SUNOS4) || defined(DARWIN) || defined(NEXTSTEP) \
-+#if defined(SUNOS4) || defined(NEXTSTEP) \
- || defined(WIN16) || defined(XP_OS2) \
- || ((defined(OPENBSD) || defined(NETBSD)) && !defined(__ELF__))
- #define NEED_LEADING_UNDERSCORE
+--- xpcom/stub/Makefile.in.orig 2009-02-04 09:50:48.000000000 +0900
++++ xpcom/stub/Makefile.in
+@@ -107,7 +107,7 @@ else
+ DEPENDENT_LIBS_LIST += $(LIB_PREFIX)mozjs$(DLL_SUFFIX)
+ endif
+
+-ifeq (Darwin,$(OS_ARCH))
++ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
+ EXTRA_DSO_LDOPTS += $(DIST)/bin/XUL
+ DEPENDENT_LIBS_LIST += XUL
+ else
+@@ -129,6 +129,13 @@ endif
+
+ EXTRA_DSO_LDOPTS += $(EXTRA_DSO_LIBS) $(NSPR_LIBS)
+
++ifeq (Darwin,$(OS_ARCH))
++_libs_to_fix = \
++ -lmozjs \
++ $(filter -l%, $(NSS_LIBS))
++EXTRA_DSO_LDOPTS += $(foreach library, $(patsubst -l%, $(LIB_PREFIX)%$(DLL_SUFFIX), $(_libs_to_fix)), -dylib_file $(libdir)/$(MOZILLA_PKG_NAME)/$(library):$(DIST)/bin/$(library))
++endif
++
+ include $(topsrcdir)/config/rules.mk
+
+ libs:: $(FINAL_TARGET)/dependentlibs.list