Index: src/Makefile.shlib
--- src/Makefile.shlib.orig	2009-01-05 10:27:19 +0100
+++ src/Makefile.shlib	2009-07-12 11:40:16 +0200
@@ -339,7 +339,7 @@
 
 .PHONY: all-lib all-static-lib all-shared-lib
 
-all-lib: all-shared-lib
+all-lib:
 ifdef soname
 # no static library when building a dynamically loadable module
 all-lib: all-static-lib
Index: src/backend/Makefile
--- src/backend/Makefile.orig	2009-01-01 18:23:34 +0100
+++ src/backend/Makefile	2009-07-12 11:40:16 +0200
@@ -32,7 +32,7 @@
 LIBS := $(filter-out -lpgport, $(LIBS)) $(LDAP_LIBS_BE)
 
 # The backend doesn't need everything that's in LIBS, however
-LIBS := $(filter-out -lz -lreadline -ledit -ltermcap -lncurses -lcurses, $(LIBS))
+LIBS := $(filter-out -lreadline -ledit -ltermcap -lncurses -lcurses, $(LIBS))
 
 ##########################################################################
 
Index: src/include/port.h
--- src/include/port.h.orig	2009-06-11 16:49:08 +0200
+++ src/include/port.h	2009-07-12 11:40:16 +0200
@@ -360,7 +360,7 @@
 extern int	getopt(int nargc, char *const * nargv, const char *ostr);
 #endif
 
-#ifndef HAVE_ISINF
+#if !defined(HAVE_ISINF) && !defined(__FreeBSD__)
 extern int	isinf(double x);
 #endif
 
Index: src/makefiles/Makefile.freebsd
--- src/makefiles/Makefile.freebsd.orig	2008-11-14 11:22:47 +0100
+++ src/makefiles/Makefile.freebsd	2009-07-12 11:41:40 +0200
@@ -16,7 +16,7 @@
 
 %.so: %.o
 ifdef ELF_SYSTEM
-	$(CC) $(CFLAGS) -shared -o $@ $<
+	$(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ $< $(SHLIB_LINK)
 else
 	$(LD) $(LDREL) $(LDOUT) $<.obj -x $<
 	@echo building shared object $@
Index: src/makefiles/Makefile.linux
--- src/makefiles/Makefile.linux.orig	2008-11-14 11:22:47 +0100
+++ src/makefiles/Makefile.linux	2009-07-12 11:42:16 +0200
@@ -11,4 +11,4 @@
 endif
 
 %.so: %.o
-	$(CC) $(CFLAGS) -shared -o $@ $<
+	$(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ $< $(SHLIB_LINK)
Index: src/makefiles/Makefile.solaris
--- src/makefiles/Makefile.solaris.orig	2009-07-12 11:40:16 +0200
+++ src/makefiles/Makefile.solaris	2009-07-12 11:42:07 +0200
@@ -18,7 +18,7 @@
 
 %.so: %.o
 ifeq ($(GCC), yes)
-	$(CC) $(CFLAGS) -shared -o $@ $<
+	$(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ $< $(SHLIB_LINK)
 else
 	$(CC) $(CFLAGS) -G -o $@ $<
 endif
