diff --git a/Makefile b/Makefile
index 7d763d8..6085802 100644
--- a/Makefile
+++ b/Makefile
@@ -91,7 +91,23 @@ installdir-plugins:
 ## Rules for making the debugger plugin.
 ##
 ## 
+ifeq ($(PORTNAME), darwin)
+ifeq ($(MAJORVERSION), 8.4)
+define filter-dups
+$(strip $(eval __lib_tmp:=)\
+    $(foreach word,$(1),$(if $(filter-out $(__lib_tmp),$(word)),$(word),)\
+              $(eval __lib_tmp:=$(__lib_tmp) $(word))\
+    )\
+)
+endef
+plugin_debugger$(DLSUFFIX): $(PLUGIN_OBJS)
+	$(LINK.shared) $(LDFLAGS_SL) $(OBJS) $(call filter-dups, $(SHLIB_LINK)) -o $@
+else
 plugin_debugger$(DLSUFFIX): $(PLUGIN_OBJS)
+endif
+else
+plugin_debugger$(DLSUFFIX): $(PLUGIN_OBJS)
+endif
 
 plpgsql_debugger.o: CFLAGS += -I$(top_builddir)/src/pl/plpgsql/src
 
