--- src/include/port.h.orig	2009-11-14 16:39:41.000000000 +0100
+++ src/include/port.h	2010-03-10 13:17:27.000000000 +0100
@@ -337,6 +337,7 @@
  * When necessary, these routines are provided by files in src/port/.
  */
 #ifndef HAVE_CRYPT
+#define crypt pq_crypt
 extern char *crypt(const char *key, const char *setting);
 #endif
 
@@ -351,44 +352,60 @@
 #endif
 
 #ifndef HAVE_GETOPT
+#define getopt pq_getopt
 extern int	getopt(int nargc, char *const * nargv, const char *ostr);
 #endif
 
 #ifndef HAVE_ISINF
+#define isinf pq_isinf
 extern int	isinf(double x);
 #endif
 
 #ifndef HAVE_RINT
+#define rint pq_rint
 extern double rint(double x);
 #endif
 
 #ifndef HAVE_INET_ATON
 #include <netinet/in.h>
 #include <arpa/inet.h>
+#define inet_aton pq_inet_aton
 extern int	inet_aton(const char *cp, struct in_addr * addr);
 #endif
 
 #ifndef HAVE_STRDUP
+#define strdup pq_strdup
 extern char *strdup(const char *str);
 #endif
 
+#ifndef HAVE_STRLCAT
+#define strlcat pq_strlcat
+#endif
+
 #if !HAVE_DECL_STRLCAT
 extern size_t strlcat(char *dst, const char *src, size_t siz);
 #endif
 
+#ifndef HAVE_STRLCPY
+#define strlcpy pq_strlcpy
+#endif
+
 #if !HAVE_DECL_STRLCPY
 extern size_t strlcpy(char *dst, const char *src, size_t siz);
 #endif
 
 #if !defined(HAVE_RANDOM) && !defined(__BORLANDC__)
+#define random pq_random
 extern long random(void);
 #endif
 
 #ifndef HAVE_UNSETENV
+#define unsetenv pq_unsetenv
 extern void unsetenv(const char *name);
 #endif
 
 #ifndef HAVE_SRANDOM
+#define srandom pq_srandom
 extern void srandom(unsigned int seed);
 #endif
 
--- src/Makefile.global.in.orig	2007-11-13 01:13:19.000000000 +0100
+++ src/Makefile.global.in	2010-03-10 13:42:04.000000000 +0100
@@ -435,9 +435,10 @@
 endif
 
 # to make ws2_32.lib the last library, and always link with shfolder,
-# so SHGetFolderName isn't picked up from shell32.dll
+# so SHGetFolderName isn't picked up from shell32.dll.  Also link
+# with secur32 for SSPI.
 ifeq ($(PORTNAME),win32)
-LIBS += -lws2_32 -lshfolder
+LIBS += -lws2_32 -lshfolder -lsecur32
 endif
 
 # Not really standard libc functions, used by the backend.
--- src/template/win32.orig	2004-11-08 06:23:26.000000000 +0100
+++ src/template/win32	2010-03-10 13:40:59.000000000 +0100
@@ -1,4 +1,4 @@
 # This is required to link pg_dump because it finds pg_toupper() in
 # libpq and pgport
-LDFLAGS="-Wl,--allow-multiple-definition"
+LDFLAGS="${LDFLAGS} -Wl,--allow-multiple-definition"
 
