
--- postgresql-7.4.19/contrib/Makefile	2003-09-11 13:15:27.000000000 -0400
+++ postgresql-7.4.19-new/contrib/Makefile	2008-01-15 10:55:01.000000000 -0500
@@ -37,7 +37,6 @@
 		string		\
 		tablefunc	\
 		tips		\
-		tsearch		\
 		tsearch2	\
 		userlock	\
 		vacuumlo
--- postgresql-7.4.19/contrib/btree_gist/Makefile	2003-03-20 13:59:18.000000000 -0500
+++ postgresql-7.4.19-new/contrib/btree_gist/Makefile	2008-01-15 10:55:01.000000000 -0500
@@ -1,5 +1,7 @@
+DLTYPE = module
 
 subdir = contrib/btree_gist
+
 top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
--- postgresql-7.4.19/contrib/chkpass/Makefile	2002-10-21 14:55:10.000000000 -0400
+++ postgresql-7.4.19-new/contrib/chkpass/Makefile	2008-01-15 10:55:01.000000000 -0500
@@ -1,5 +1,7 @@
 # $Header: /cvsroot/pgsql/contrib/chkpass/Makefile,v 1.4 2002/10/21 18:55:10 petere Exp $
 
+DLTYPE = module
+
 subdir = contrib/chkpass
 top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
--- postgresql-7.4.19/contrib/contrib-global.mk	2003-08-23 00:23:38.000000000 -0400
+++ postgresql-7.4.19-new/contrib/contrib-global.mk	2008-01-15 10:55:01.000000000 -0500
@@ -42,6 +42,9 @@
 #
 # Better look at some of the existing uses for examples...
 
+ifeq ($(DLTYPE), bundle)
+override DARWIN_LINKFLAGS := $(DARWIN_LINKFLAGS) -bundle_loader $(top_srcdir)/src/backend/postgres
+endif
 
 override CPPFLAGS := -I$(srcdir) $(CPPFLAGS)
 
--- postgresql-7.4.19/contrib/cube/Makefile	2003-09-13 21:52:25.000000000 -0400
+++ postgresql-7.4.19-new/contrib/cube/Makefile	2008-01-15 10:55:01.000000000 -0500
@@ -1,5 +1,7 @@
 # $Header: /cvsroot/pgsql/contrib/cube/Makefile,v 1.10 2003/09/14 01:52:25 tgl Exp $
 
+DLTYPE = module
+
 subdir = contrib/cube
 top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
--- postgresql-7.4.19/contrib/dblink/Makefile	2002-09-14 16:28:54.000000000 -0400
+++ postgresql-7.4.19-new/contrib/dblink/Makefile	2008-01-15 10:55:01.000000000 -0500
@@ -1,5 +1,7 @@
 # $Header: /cvsroot/pgsql/contrib/dblink/Makefile,v 1.7 2002/09/14 20:28:54 tgl Exp $
 
+DLTYPE = module
+
 subdir = contrib/dblink
 top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
--- postgresql-7.4.19/contrib/dbmirror/Makefile	2002-06-23 17:58:07.000000000 -0400
+++ postgresql-7.4.19-new/contrib/dbmirror/Makefile	2008-01-15 10:55:01.000000000 -0500
@@ -1,5 +1,7 @@
 # $Header: /cvsroot/pgsql/contrib/dbmirror/Attic/Makefile,v 1.1 2002/06/23 21:58:07 momjian Exp $
 
+DLTYPE = module
+
 subdir = contrib/dbmirror
 top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
--- postgresql-7.4.19/contrib/dbsize/Makefile	2002-02-22 18:05:35.000000000 -0500
+++ postgresql-7.4.19-new/contrib/dbsize/Makefile	2008-01-15 10:55:01.000000000 -0500
@@ -1,3 +1,5 @@
+DLTYPE = module
+
 subdir = contrib/dbsize
 top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
--- postgresql-7.4.19/contrib/earthdistance/Makefile	2002-09-19 23:47:22.000000000 -0400
+++ postgresql-7.4.19-new/contrib/earthdistance/Makefile	2008-01-15 10:55:01.000000000 -0500
@@ -1,5 +1,7 @@
 # $Header: /cvsroot/pgsql/contrib/earthdistance/Makefile,v 1.12 2002/09/20 03:47:22 momjian Exp $
 
+DLTYPE = module
+
 subdir = contrib/earthdistance
 top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
--- postgresql-7.4.19/contrib/fulltextindex/Makefile	2001-09-06 06:49:29.000000000 -0400
+++ postgresql-7.4.19-new/contrib/fulltextindex/Makefile	2008-01-15 10:55:01.000000000 -0500
@@ -1,5 +1,7 @@
 # $Header: /cvsroot/pgsql/contrib/fulltextindex/Attic/Makefile,v 1.11 2001/09/06 10:49:29 petere Exp $
 
+DLTYPE = module
+
 subdir = contrib/fulltextindex
 top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
--- postgresql-7.4.19/contrib/fuzzystrmatch/Makefile	2001-09-06 06:49:29.000000000 -0400
+++ postgresql-7.4.19-new/contrib/fuzzystrmatch/Makefile	2008-01-15 10:55:01.000000000 -0500
@@ -1,5 +1,7 @@
 # $Header: /cvsroot/pgsql/contrib/fuzzystrmatch/Makefile,v 1.2 2001/09/06 10:49:29 petere Exp $
 
+DLTYPE = module
+
 subdir = contrib/fuzzystrmatch
 top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
--- postgresql-7.4.19/contrib/intagg/Makefile	2002-02-24 23:16:58.000000000 -0500
+++ postgresql-7.4.19-new/contrib/intagg/Makefile	2008-01-15 10:55:01.000000000 -0500
@@ -4,6 +4,8 @@
 # by Mark L. Woodward
 # $Header: /cvsroot/pgsql/contrib/intagg/Makefile,v 1.3 2002/02/25 04:16:58 tgl Exp $
 
+DLTYPE = module
+
 subdir = contrib/intagg
 top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
--- postgresql-7.4.19/contrib/intarray/Makefile	2003-06-11 14:44:14.000000000 -0400
+++ postgresql-7.4.19-new/contrib/intarray/Makefile	2008-01-15 10:55:01.000000000 -0500
@@ -1,5 +1,7 @@
 # $Header: /cvsroot/pgsql/contrib/intarray/Makefile,v 1.9 2003/06/11 18:44:14 momjian Exp $
 
+DLTYPE = module
+
 subdir = contrib/intarray
 top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
--- postgresql-7.4.19/contrib/isbn_issn/Makefile	2001-09-06 06:49:29.000000000 -0400
+++ postgresql-7.4.19-new/contrib/isbn_issn/Makefile	2008-01-15 10:55:01.000000000 -0500
@@ -1,5 +1,7 @@
 # $Header: /cvsroot/pgsql/contrib/isbn_issn/Attic/Makefile,v 1.11 2001/09/06 10:49:29 petere Exp $
 
+DLTYPE = module
+
 subdir = contrib/isbn_issn
 top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
--- postgresql-7.4.19/contrib/lo/Makefile	2001-09-06 06:49:29.000000000 -0400
+++ postgresql-7.4.19-new/contrib/lo/Makefile	2008-01-15 10:55:01.000000000 -0500
@@ -1,5 +1,7 @@
 # $Header: /cvsroot/pgsql/contrib/lo/Makefile,v 1.11 2001/09/06 10:49:29 petere Exp $
 
+DLTYPE = module
+
 subdir = contrib/lo
 top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
--- postgresql-7.4.19/contrib/ltree/Makefile	2002-11-01 18:16:52.000000000 -0500
+++ postgresql-7.4.19-new/contrib/ltree/Makefile	2008-01-15 10:55:01.000000000 -0500
@@ -1,3 +1,5 @@
+DLTYPE = module
+
 subdir = contrib/ltree
 top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
--- postgresql-7.4.19/contrib/miscutil/Makefile	2001-09-06 06:49:29.000000000 -0400
+++ postgresql-7.4.19-new/contrib/miscutil/Makefile	2008-01-15 10:55:01.000000000 -0500
@@ -1,5 +1,7 @@
 # $Header: /cvsroot/pgsql/contrib/miscutil/Attic/Makefile,v 1.16 2001/09/06 10:49:29 petere Exp $
 
+DLTYPE = module
+
 subdir = contrib/miscutil
 top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
--- postgresql-7.4.19/contrib/noupdate/Makefile	2001-09-06 06:49:29.000000000 -0400
+++ postgresql-7.4.19-new/contrib/noupdate/Makefile	2008-01-15 10:55:01.000000000 -0500
@@ -1,5 +1,7 @@
 # $Header: /cvsroot/pgsql/contrib/noupdate/Attic/Makefile,v 1.9 2001/09/06 10:49:29 petere Exp $
 
+DLTYPE = module
+
 subdir = contrib/noupdate
 top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
--- postgresql-7.4.19/contrib/pgcrypto/Makefile	2001-09-30 18:18:29.000000000 -0400
+++ postgresql-7.4.19-new/contrib/pgcrypto/Makefile	2008-01-15 10:55:01.000000000 -0500
@@ -2,6 +2,9 @@
 # $Header: /cvsroot/pgsql/contrib/pgcrypto/Makefile,v 1.9 2001/09/30 22:18:29 momjian Exp $
 #
 
+DLTYPE = module
+
+
 subdir = contrib/pgcrypto
 top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
--- postgresql-7.4.19/contrib/pgstattuple/Makefile	2001-09-30 21:52:38.000000000 -0400
+++ postgresql-7.4.19-new/contrib/pgstattuple/Makefile	2008-01-15 10:55:01.000000000 -0500
@@ -6,6 +6,8 @@
 #
 #-------------------------------------------------------------------------
 
+DLTYPE = module
+
 subdir = contrib/pgstattuple
 top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
--- postgresql-7.4.19/contrib/rserv/Makefile	2002-11-01 18:45:37.000000000 -0500
+++ postgresql-7.4.19-new/contrib/rserv/Makefile	2008-01-15 10:55:01.000000000 -0500
@@ -1,6 +1,8 @@
 # Makefile for erServer demonstration implementation
 # (c) 2000 Vadim Mikheev, PostgreSQL Inc.
 
+DLTYPE = module
+
 subdir = contrib/rserv
 top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
--- postgresql-7.4.19/contrib/rtree_gist/Makefile	2001-09-06 06:49:30.000000000 -0400
+++ postgresql-7.4.19-new/contrib/rtree_gist/Makefile	2008-01-15 10:55:01.000000000 -0500
@@ -1,5 +1,7 @@
 # $Header: /cvsroot/pgsql/contrib/rtree_gist/Attic/Makefile,v 1.3 2001/09/06 10:49:30 petere Exp $
 
+DLTYPE = module
+
 subdir = contrib/rtree_gist
 top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
--- postgresql-7.4.19/contrib/seg/Makefile	2003-09-13 22:18:49.000000000 -0400
+++ postgresql-7.4.19-new/contrib/seg/Makefile	2008-01-15 10:55:01.000000000 -0500
@@ -1,5 +1,7 @@
 # $Header: /cvsroot/pgsql/contrib/seg/Makefile,v 1.10 2003/09/14 02:18:49 tgl Exp $
 
+DLTYPE = module
+
 subdir = contrib/seg
 top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
--- postgresql-7.4.19/contrib/spi/Makefile	2002-10-03 14:40:02.000000000 -0400
+++ postgresql-7.4.19-new/contrib/spi/Makefile	2008-01-15 10:55:01.000000000 -0500
@@ -1,5 +1,7 @@
 # $Header: /cvsroot/pgsql/contrib/spi/Makefile,v 1.22 2002/10/03 18:40:02 tgl Exp $
 
+DLTYPE = module
+
 subdir = contrib/spi
 top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
--- postgresql-7.4.19/contrib/string/Makefile	2001-09-06 06:49:30.000000000 -0400
+++ postgresql-7.4.19-new/contrib/string/Makefile	2008-01-15 10:55:01.000000000 -0500
@@ -1,5 +1,7 @@
 # $Header: /cvsroot/pgsql/contrib/string/Attic/Makefile,v 1.16 2001/09/06 10:49:30 petere Exp $
 
+DLTYPE = module
+
 subdir = contrib/string
 top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
--- postgresql-7.4.19/contrib/tablefunc/Makefile	2002-09-11 20:14:40.000000000 -0400
+++ postgresql-7.4.19-new/contrib/tablefunc/Makefile	2008-01-15 10:55:01.000000000 -0500
@@ -1,3 +1,5 @@
+DLTYPE = module
+
 subdir = contrib/tablefunc
 top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
--- postgresql-7.4.19/contrib/tsearch/Makefile	2002-11-01 18:23:29.000000000 -0500
+++ postgresql-7.4.19-new/contrib/tsearch/Makefile	2008-01-15 10:55:01.000000000 -0500
@@ -1,5 +1,7 @@
 # $Header: /cvsroot/pgsql/contrib/tsearch/Attic/Makefile,v 1.3 2002/11/01 23:23:29 tgl Exp $
 
+DLTYPE = module
+
 subdir = contrib/tsearch
 top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
--- postgresql-7.4.19/contrib/tsearch2/Makefile	2003-08-26 06:01:02.000000000 -0400
+++ postgresql-7.4.19-new/contrib/tsearch2/Makefile	2008-01-15 10:55:01.000000000 -0500
@@ -1,5 +1,7 @@
 # $Header: /cvsroot/pgsql/contrib/tsearch2/Makefile,v 1.5 2003/08/26 10:01:02 teodor Exp $
 
+DLTYPE = module
+
 subdir = contrib/tsearch2
 top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
--- postgresql-7.4.19/contrib/userlock/Makefile	2001-09-06 06:49:30.000000000 -0400
+++ postgresql-7.4.19-new/contrib/userlock/Makefile	2008-01-15 10:55:01.000000000 -0500
@@ -1,5 +1,7 @@
 # $Header: /cvsroot/pgsql/contrib/userlock/Attic/Makefile,v 1.16 2001/09/06 10:49:30 petere Exp $
 
+DLTYPE = module
+
 subdir = contrib/userlock
 top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
--- postgresql-7.4.19/contrib/xml/Makefile	2002-10-22 16:03:09.000000000 -0400
+++ postgresql-7.4.19-new/contrib/xml/Makefile	2008-01-15 10:55:01.000000000 -0500
@@ -1,5 +1,7 @@
 # $Header: /cvsroot/pgsql/contrib/xml/Attic/Makefile,v 1.3 2002/10/22 20:03:09 petere Exp $
 
+DLTYPE = module
+
 subdir = contrib/xml
 top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
--- postgresql-7.4.19/pgsql.sh	1969-12-31 19:00:00.000000000 -0500
+++ postgresql-7.4.19-new/pgsql.sh	2008-01-15 11:04:20.000000000 -0500
@@ -0,0 +1,73 @@
+#!/bin/sh
+
+die () {
+	echo "failed"
+	echo ""
+	echo "*** bailing because an error ocurred:"
+	echo ""
+	echo "$*"
+	exit 1
+}
+
+PREFIX="@INSTPREFIX@"
+DATADIR="${PREFIX}/var/postgresql-7.4/data"
+LOGFILE="${PREFIX}/var/postgresql-7.4/pgsql.log"
+
+export LANG=C
+unset LC_ALL
+
+SHMMAX=`sysctl kern.sysv.shmmax | cut -d' ' -f2-`
+SHMMNI=`sysctl kern.sysv.shmmni | cut -d' ' -f2-`
+SHMALL=`sysctl kern.sysv.shmall | cut -d' ' -f2-`
+
+if [ "$SHMMAX" -lt "8388608" ] || [ "$SHMMNI" -lt "64" ] || [ "$SHMALL" -lt "32768" ]; then
+	echo "WARNING: You probably need to set your shared memory resources higher for"
+	echo "         PostgreSQL to function.  For more information on raising your shared"
+	echo "         memory settings, see:"
+	echo "         http://wiki.finkproject.org/index.php/Shared_Memory_Regions_on_Darwin"
+	echo ""
+	echo "         I am also creating a default configuration in /etc/sysctl.conf.pg"
+	echo "         that contains values that will work with the default PostgreSQL "
+	echo "         memory settings.  To use it, rename it to /etc/sysctl.conf (if you"
+	echo "         don't have one already) and reboot."
+	echo ""
+	echo "         For now, I'll try setting your sysctl to something higher and then"
+	echo "         running things anyways.  Good luck!  =)"
+	echo ""
+	sysctl -w kern.sysv.shmmax=8388608
+	sysctl -w kern.sysv.shmmin=1
+	sysctl -w kern.sysv.shmmni=64
+	sysctl -w kern.sysv.shmseg=8
+	sysctl -w kern.sysv.shmall=32768
+	echo ""
+	cat <<END >/etc/sysctl.conf.pg
+kern.sysv.shmmax=8388608
+kern.sysv.shmmin=1
+kern.sysv.shmmni=64
+kern.sysv.shmseg=8
+kern.sysv.shmall=32768
+END
+fi
+
+if [ ! -d "$DATADIR" ]; then
+	printf -- "- making postgresql directories: "
+	sudo mkdir -p "$DATADIR"
+	sudo chown -R postgres "$DATADIR/.."
+	echo "ok"
+
+	printf -- "- initializing database in $DATADIR: "
+	sudo -u postgres ${PREFIX}/bin/initdb-7.4 -D "$DATADIR" >/tmp/pgsql-init-7.4.log 2>&1 || die "couldn't initialize database"
+	echo "ok"
+fi
+
+case "$1" in
+	start)
+		unset LC_ALL; LANG=C sudo -u postgres "${PREFIX}/bin/pg_ctl-7.4" start -D "$DATADIR" -l "$LOGFILE"
+		;;
+	restart)
+		unset LC_ALL; LANG=C sudo -u postgres "${PREFIX}/bin/pg_ctl-7.4" restart -D "$DATADIR" -m fast
+		;;
+	stop)
+		unset LC_ALL; LANG=C sudo -u postgres "${PREFIX}/bin/pg_ctl-7.4" stop -D "$DATADIR" -m fast
+		;;
+esac
--- postgresql-7.4.19/src/Makefile.global.in	2003-12-19 18:29:29.000000000 -0500
+++ postgresql-7.4.19-new/src/Makefile.global.in	2008-01-15 10:55:01.000000000 -0500
@@ -65,21 +65,21 @@
 libexecdir := @libexecdir@
 ifeq "$(findstring pgsql, $(libexecdir))" ""
 ifeq "$(findstring postgres, $(libexecdir))" ""
-override libexecdir := $(libexecdir)/postgresql
+override libexecdir := $(libexecdir)/postgresql-7.4
 endif
 endif
 
 datadir := @datadir@
 ifeq "$(findstring pgsql, $(datadir))" ""
 ifeq "$(findstring postgres, $(datadir))" ""
-override datadir := $(datadir)/postgresql
+override datadir := $(datadir)/postgresql-7.4
 endif
 endif
 
 sysconfdir := @sysconfdir@
 ifeq "$(findstring pgsql, $(sysconfdir))" ""
 ifeq "$(findstring postgres, $(sysconfdir))" ""
-override sysconfdir := $(sysconfdir)/postgresql
+override sysconfdir := $(sysconfdir)/postgresql-7.4
 endif
 endif
 
@@ -87,7 +87,7 @@
 pkglibdir = $(libdir)
 ifeq "$(findstring pgsql, $(pkglibdir))" ""
 ifeq "$(findstring postgres, $(pkglibdir))" ""
-override pkglibdir := $(pkglibdir)/postgresql
+override pkglibdir := $(pkglibdir)/postgresql-7.4
 endif
 endif
 
@@ -95,7 +95,7 @@
 pkgincludedir = $(includedir)
 ifeq "$(findstring pgsql, $(pkgincludedir))" ""
 ifeq "$(findstring postgres, $(pkgincludedir))" ""
-override pkgincludedir := $(pkgincludedir)/postgresql
+override pkgincludedir := $(pkgincludedir)/postgresql-7.4
 endif
 endif
 includedir_server = $(pkgincludedir)/server
@@ -107,7 +107,7 @@
 docdir := @docdir@
 ifeq "$(findstring pgsql, $(docdir))" ""
 ifeq "$(findstring postgres, $(docdir))" ""
-override docdir := $(docdir)/postgresql
+override docdir := $(docdir)/postgresql-7.4
 endif
 endif
 
--- postgresql-7.4.19/src/Makefile.shlib	2005-12-03 15:17:00.000000000 -0500
+++ postgresql-7.4.19-new/src/Makefile.shlib	2008-01-15 10:55:01.000000000 -0500
@@ -87,8 +87,24 @@
 endif
 
 ifeq ($(PORTNAME), darwin)
-  shlib			:= lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
-  LINK.shared		= $(COMPILER) -bundle
+  ifeq (,$(filter $(host_os), darwin1.0 darwin1.1 darwin1.2))
+     DARWIN_LINKFLAGS  =
+  else
+     DARWIN_LINKFLAGS  = -multiply_defined suppress
+  endif
+
+  shlib			:= lib$(NAME).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)$(DLSUFFIX)
+  ifneq ($(SO_MAJOR_VERSION), 0)
+    version_link	:= -compatibility_version $(SO_MAJOR_VERSION) -current_version $(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
+  endif
+  ifeq ($(DLTYPE), module)
+    DLSUFFIX		:= .so
+    LINK.shared		= $(COMPILER) $(DARWIN_NAMESPACE_SPEC) -bundle -undefined suppress -flat_namespace
+  else
+    DLSUFFIX		:= .dylib
+    LINK.shared		= $(COMPILER) $(DARWIN_NAMESPACE_SPEC) -install_name $(libdir)/lib$(NAME).$(SO_MAJOR_VERSION)$(DLSUFFIX) $(version_link) -dynamiclib $(DARWIN_LINKFLAGS)
+  endif
+  SHLIB_LINK		:= -L$(libpq_builddir) $(SHLIB_LINK)
 endif
 
 ifeq ($(PORTNAME), openbsd)
@@ -254,6 +270,7 @@
 ifneq ($(PORTNAME), beos)
 ifneq ($(PORTNAME), cygwin)
 ifneq ($(PORTNAME), aix)
+ifneq ($(PORTNAME), darwin)
 
 # Normal case
 $(shlib): $(OBJS)
@@ -269,6 +286,25 @@
 	$(LN_S) $(shlib) lib$(NAME)$(DLSUFFIX)
 endif
 
+else # PORTNAME == darwin
+
+# Darwin case
+# (same as normal case, but libfoo.version.suffix)
+
+$(shlib): $(OBJS)
+	$(LINK.shared) $(OBJS) $(SHLIB_LINK) -o $@
+ifneq ($(shlib), lib$(NAME).$(SO_MAJOR_VERSION)$(DLSUFFIX))
+	rm -f lib$(NAME).$(SO_MAJOR_VERSION)$(DLSUFFIX)
+	$(LN_S) $(shlib) lib$(NAME).$(SO_MAJOR_VERSION)$(DLSUFFIX)
+endif
+
+ifneq ($(shlib), lib$(NAME)$(DLSUFFIX))
+	rm -f lib$(NAME)$(DLSUFFIX)
+	$(LN_S) $(shlib) lib$(NAME)$(DLSUFFIX)
+endif
+
+endif # PORTNAME == darwin
+
 else # PORTNAME == aix
 
 # AIX case
@@ -321,6 +357,7 @@
 install-lib-shared: $(shlib)
 	$(INSTALL_SHLIB) $< $(DESTDIR)$(libdir)/$(shlib)
 ifneq ($(PORTNAME), cygwin)
+ifneq ($(PORTNAME), darwin)
 ifneq ($(shlib), lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION))
 	cd $(DESTDIR)$(libdir) && \
 	rm -f lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION) && \
@@ -331,7 +368,18 @@
 	rm -f lib$(NAME)$(DLSUFFIX) && \
 	$(LN_S) $(shlib) lib$(NAME)$(DLSUFFIX)
 endif
-
+else
+ifneq ($(shlib), lib$(NAME).$(SO_MAJOR_VERSION)$(DLSUFFIX))
+	cd $(DESTDIR)$(libdir) && \
+	rm -f lib$(NAME).$(SO_MAJOR_VERSION)$(DLSUFFIX) && \
+	$(LN_S) $(shlib) lib$(NAME).$(SO_MAJOR_VERSION)$(DLSUFFIX)
+endif
+ifneq ($(shlib), lib$(NAME)$(DLSUFFIX))
+	cd $(DESTDIR)$(libdir) && \
+	rm -f lib$(NAME)$(DLSUFFIX) && \
+	$(LN_S) $(shlib) lib$(NAME)$(DLSUFFIX)
+endif
+endif # not darwin
 endif # not cygwin
 endif # enable_shared
 
@@ -346,7 +394,9 @@
 ifeq ($(enable_shared), yes)
 	rm -f $(DESTDIR)$(libdir)/lib$(NAME)$(DLSUFFIX) \
 	  $(DESTDIR)$(libdir)/lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION) \
-	  $(DESTDIR)$(libdir)/lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
+	  $(DESTDIR)$(libdir)/lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION) \
+	  $(DESTDIR)$(libdir)/lib$(NAME).$(SO_MAJOR_VERSION)$(DLSUFFIX) \
+	  $(DESTDIR)$(libdir)/lib$(NAME).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)$(DLSUFFIX)
 endif # enable_shared
 
 
@@ -358,7 +408,7 @@
 clean-lib:
 	rm -f lib$(NAME).a
 ifeq ($(enable_shared), yes)
-	rm -f lib$(NAME)$(DLSUFFIX) lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION) lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
+	rm -f lib$(NAME)$(DLSUFFIX) lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION) lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION) lib$(NAME).$(SO_MAJOR_VERSION)$(DLSUFFIX) lib$(NAME).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)$(DLSUFFIX)
 ifdef EXPSUFF
 	rm -f lib$(NAME)$(EXPSUFF)
 endif
--- postgresql-7.4.19/src/backend/main/main.c	2006-01-04 19:55:23.000000000 -0500
+++ postgresql-7.4.19-new/src/backend/main/main.c	2008-01-15 10:55:01.000000000 -0500
@@ -51,6 +51,7 @@
 	int			len;
 	struct passwd *pw;
 	char	   *pw_name_persist;
+	char	   *progname;
 
 	/*
 	 * Place platform-specific startup hacks here.	This is the right
@@ -214,9 +215,27 @@
 	 * argument) we were called with.  The lack of consistency here is
 	 * historical.
 	 */
-	len = strlen(new_argv[0]);
 
-	if (len >= 10 && strcmp(new_argv[0] + len - 10, "postmaster") == 0)
+	/*
+	 * Find the program name, which is after the final slash in the
+	 * program argument.
+	 */
+	progname = strrchr(new_argv[0], '/');
+	if (progname != NULL)
+	{
+		progname = progname + 1;
+        } 
+	else 
+	{
+		progname = new_argv[0];
+	}
+
+	/*
+	 * Now check if the program name starts with the
+	 * word "postmaster", in which case PostmasterMain is called.
+	 */
+	len = strlen(progname);
+	if (len >= 10 && strncmp(progname, "postmaster", 10) == 0)
 	{
 		/* Called as "postmaster" */
 		exit(PostmasterMain(argc, new_argv));
--- postgresql-7.4.19/src/backend/utils/fmgr/dfmgr.c	2003-09-25 02:58:05.000000000 -0400
+++ postgresql-7.4.19-new/src/backend/utils/fmgr/dfmgr.c	2008-01-15 10:55:01.000000000 -0500
@@ -300,6 +300,26 @@
 		pfree(full);
 	}
 
+	new = palloc(strlen(name) + strlen(".so") + 1);
+	strcpy(new, name);
+	strcat(new, ".so");
+
+	if (!have_slash)
+	{
+		full = find_in_dynamic_libpath(new);
+		pfree(new);
+		if (full)
+			return full;
+	}
+	else
+	{
+		full = substitute_libpath_macro(new);
+		pfree(new);
+		if (file_exists(full))
+			return full;
+		pfree(full);
+	}
+
 	new = palloc(strlen(name) + strlen(DLSUFFIX) + 1);
 	strcpy(new, name);
 	strcat(new, DLSUFFIX);
--- postgresql-7.4.19/src/backend/utils/mb/conversion_procs/ascii_and_mic/Makefile	2002-08-21 22:18:45.000000000 -0400
+++ postgresql-7.4.19-new/src/backend/utils/mb/conversion_procs/ascii_and_mic/Makefile	2008-01-15 10:55:01.000000000 -0500
@@ -3,6 +3,9 @@
 # $Id: Makefile,v 1.3 2002/08/22 02:18:45 momjian Exp $
 #
 #-------------------------------------------------------------------------
+
+DLTYPE = module
+
 subdir = src/backend/utils/mb/conversion_procs/ascii_and_mic
 top_builddir = ../../../../../..
 include $(top_builddir)/src/Makefile.global
--- postgresql-7.4.19/src/backend/utils/mb/conversion_procs/cyrillic_and_mic/Makefile	2002-08-21 17:33:55.000000000 -0400
+++ postgresql-7.4.19-new/src/backend/utils/mb/conversion_procs/cyrillic_and_mic/Makefile	2008-01-15 10:55:01.000000000 -0500
@@ -3,6 +3,9 @@
 # $Id: Makefile,v 1.2 2002/08/21 21:33:55 momjian Exp $
 #
 #-------------------------------------------------------------------------
+
+DLTYPE = module
+
 subdir = src/backend/utils/mb/conversion_procs/cyrillic_and_mic
 top_builddir = ../../../../../..
 include $(top_builddir)/src/Makefile.global
--- postgresql-7.4.19/src/backend/utils/mb/conversion_procs/euc_cn_and_mic/Makefile	2002-08-21 17:33:55.000000000 -0400
+++ postgresql-7.4.19-new/src/backend/utils/mb/conversion_procs/euc_cn_and_mic/Makefile	2008-01-15 10:55:01.000000000 -0500
@@ -3,6 +3,9 @@
 # $Id: Makefile,v 1.2 2002/08/21 21:33:55 momjian Exp $
 #
 #-------------------------------------------------------------------------
+
+DLTYPE = module
+
 subdir = src/backend/utils/mb/conversion_procs/euc_cn_and_mic
 top_builddir = ../../../../../..
 include $(top_builddir)/src/Makefile.global
--- postgresql-7.4.19/src/backend/utils/mb/conversion_procs/euc_jp_and_sjis/Makefile	2002-08-21 17:33:55.000000000 -0400
+++ postgresql-7.4.19-new/src/backend/utils/mb/conversion_procs/euc_jp_and_sjis/Makefile	2008-01-15 10:55:01.000000000 -0500
@@ -3,6 +3,9 @@
 # $Id: Makefile,v 1.2 2002/08/21 21:33:55 momjian Exp $
 #
 #-------------------------------------------------------------------------
+
+DLTYPE = module
+
 subdir = src/backend/utils/mb/conversion_procs/euc_jp_and_sjis
 top_builddir = ../../../../../..
 include $(top_builddir)/src/Makefile.global
--- postgresql-7.4.19/src/backend/utils/mb/conversion_procs/euc_kr_and_mic/Makefile	2002-08-21 17:33:55.000000000 -0400
+++ postgresql-7.4.19-new/src/backend/utils/mb/conversion_procs/euc_kr_and_mic/Makefile	2008-01-15 10:55:01.000000000 -0500
@@ -3,6 +3,9 @@
 # $Id: Makefile,v 1.2 2002/08/21 21:33:55 momjian Exp $
 #
 #-------------------------------------------------------------------------
+
+DLTYPE = module
+
 subdir = src/backend/utils/mb/conversion_procs/euc_kr_and_mic
 top_builddir = ../../../../../..
 include $(top_builddir)/src/Makefile.global
--- postgresql-7.4.19/src/backend/utils/mb/conversion_procs/euc_tw_and_big5/Makefile	2002-08-21 17:33:55.000000000 -0400
+++ postgresql-7.4.19-new/src/backend/utils/mb/conversion_procs/euc_tw_and_big5/Makefile	2008-01-15 10:55:01.000000000 -0500
@@ -3,6 +3,9 @@
 # $Id: Makefile,v 1.2 2002/08/21 21:33:55 momjian Exp $
 #
 #-------------------------------------------------------------------------
+
+DLTYPE = module
+
 subdir = src/backend/utils/mb/conversion_procs/euc_tw_and_big5
 top_builddir = ../../../../../..
 include $(top_builddir)/src/Makefile.global
--- postgresql-7.4.19/src/backend/utils/mb/conversion_procs/latin2_and_win1250/Makefile	2002-08-21 17:33:55.000000000 -0400
+++ postgresql-7.4.19-new/src/backend/utils/mb/conversion_procs/latin2_and_win1250/Makefile	2008-01-15 10:55:01.000000000 -0500
@@ -3,6 +3,9 @@
 # $Id: Makefile,v 1.2 2002/08/21 21:33:55 momjian Exp $
 #
 #-------------------------------------------------------------------------
+
+DLTYPE = module
+
 subdir = src/backend/utils/mb/conversion_procs/latin2_and_win1250
 top_builddir = ../../../../../..
 include $(top_builddir)/src/Makefile.global
--- postgresql-7.4.19/src/backend/utils/mb/conversion_procs/latin_and_mic/Makefile	2002-08-21 17:33:55.000000000 -0400
+++ postgresql-7.4.19-new/src/backend/utils/mb/conversion_procs/latin_and_mic/Makefile	2008-01-15 10:55:01.000000000 -0500
@@ -3,6 +3,9 @@
 # $Id: Makefile,v 1.2 2002/08/21 21:33:55 momjian Exp $
 #
 #-------------------------------------------------------------------------
+
+DLTYPE = module
+
 subdir = src/backend/utils/mb/conversion_procs/latin_and_mic
 top_builddir = ../../../../../..
 include $(top_builddir)/src/Makefile.global
--- postgresql-7.4.19/src/backend/utils/mb/conversion_procs/utf8_and_ascii/Makefile	2002-08-21 17:33:55.000000000 -0400
+++ postgresql-7.4.19-new/src/backend/utils/mb/conversion_procs/utf8_and_ascii/Makefile	2008-01-15 10:55:01.000000000 -0500
@@ -3,6 +3,9 @@
 # $Id: Makefile,v 1.2 2002/08/21 21:33:55 momjian Exp $
 #
 #-------------------------------------------------------------------------
+
+DLTYPE = module
+
 subdir = src/backend/utils/mb/conversion_procs/utf8_and_ascii
 top_builddir = ../../../../../..
 include $(top_builddir)/src/Makefile.global
--- postgresql-7.4.19/src/backend/utils/mb/conversion_procs/utf8_and_big5/Makefile	2002-08-21 17:33:55.000000000 -0400
+++ postgresql-7.4.19-new/src/backend/utils/mb/conversion_procs/utf8_and_big5/Makefile	2008-01-15 10:55:01.000000000 -0500
@@ -3,6 +3,9 @@
 # $Id: Makefile,v 1.2 2002/08/21 21:33:55 momjian Exp $
 #
 #-------------------------------------------------------------------------
+
+DLTYPE = module
+
 subdir = src/backend/utils/mb/conversion_procs/utf8_and_big5
 top_builddir = ../../../../../..
 include $(top_builddir)/src/Makefile.global
--- postgresql-7.4.19/src/backend/utils/mb/conversion_procs/utf8_and_cyrillic/Makefile	2002-08-21 17:33:55.000000000 -0400
+++ postgresql-7.4.19-new/src/backend/utils/mb/conversion_procs/utf8_and_cyrillic/Makefile	2008-01-15 10:55:01.000000000 -0500
@@ -3,6 +3,9 @@
 # $Id: Makefile,v 1.2 2002/08/21 21:33:55 momjian Exp $
 #
 #-------------------------------------------------------------------------
+
+DLTYPE = module
+
 subdir = src/backend/utils/mb/conversion_procs/utf8_and_cyrillic
 top_builddir = ../../../../../..
 include $(top_builddir)/src/Makefile.global
--- postgresql-7.4.19/src/backend/utils/mb/conversion_procs/utf8_and_euc_cn/Makefile	2002-08-21 17:33:55.000000000 -0400
+++ postgresql-7.4.19-new/src/backend/utils/mb/conversion_procs/utf8_and_euc_cn/Makefile	2008-01-15 10:55:01.000000000 -0500
@@ -3,6 +3,9 @@
 # $Id: Makefile,v 1.2 2002/08/21 21:33:55 momjian Exp $
 #
 #-------------------------------------------------------------------------
+
+DLTYPE = module
+
 subdir = src/backend/utils/mb/conversion_procs/utf8_and_euc_cn
 top_builddir = ../../../../../..
 include $(top_builddir)/src/Makefile.global
--- postgresql-7.4.19/src/backend/utils/mb/conversion_procs/utf8_and_euc_jp/Makefile	2002-08-21 17:33:55.000000000 -0400
+++ postgresql-7.4.19-new/src/backend/utils/mb/conversion_procs/utf8_and_euc_jp/Makefile	2008-01-15 10:55:01.000000000 -0500
@@ -3,6 +3,9 @@
 # $Id: Makefile,v 1.2 2002/08/21 21:33:55 momjian Exp $
 #
 #-------------------------------------------------------------------------
+
+DLTYPE = module
+
 subdir = src/backend/utils/mb/conversion_procs/utf8_and_euc_jp
 top_builddir = ../../../../../..
 include $(top_builddir)/src/Makefile.global
--- postgresql-7.4.19/src/backend/utils/mb/conversion_procs/utf8_and_euc_kr/Makefile	2002-08-21 17:33:55.000000000 -0400
+++ postgresql-7.4.19-new/src/backend/utils/mb/conversion_procs/utf8_and_euc_kr/Makefile	2008-01-15 10:55:01.000000000 -0500
@@ -3,6 +3,9 @@
 # $Id: Makefile,v 1.2 2002/08/21 21:33:55 momjian Exp $
 #
 #-------------------------------------------------------------------------
+
+DLTYPE = module
+
 subdir = src/backend/utils/mb/conversion_procs/utf8_and_euc_kr
 top_builddir = ../../../../../..
 include $(top_builddir)/src/Makefile.global
--- postgresql-7.4.19/src/backend/utils/mb/conversion_procs/utf8_and_euc_tw/Makefile	2002-08-21 17:33:55.000000000 -0400
+++ postgresql-7.4.19-new/src/backend/utils/mb/conversion_procs/utf8_and_euc_tw/Makefile	2008-01-15 10:55:01.000000000 -0500
@@ -3,6 +3,9 @@
 # $Id: Makefile,v 1.2 2002/08/21 21:33:55 momjian Exp $
 #
 #-------------------------------------------------------------------------
+
+DLTYPE = module
+
 subdir = src/backend/utils/mb/conversion_procs/utf8_and_euc_tw
 top_builddir = ../../../../../..
 include $(top_builddir)/src/Makefile.global
--- postgresql-7.4.19/src/backend/utils/mb/conversion_procs/utf8_and_gb18030/Makefile	2002-08-21 17:33:55.000000000 -0400
+++ postgresql-7.4.19-new/src/backend/utils/mb/conversion_procs/utf8_and_gb18030/Makefile	2008-01-15 10:55:01.000000000 -0500
@@ -3,6 +3,9 @@
 # $Id: Makefile,v 1.2 2002/08/21 21:33:55 momjian Exp $
 #
 #-------------------------------------------------------------------------
+
+DLTYPE = module
+
 subdir = src/backend/utils/mb/conversion_procs/utf8_and_gb18030
 top_builddir = ../../../../../..
 include $(top_builddir)/src/Makefile.global
--- postgresql-7.4.19/src/backend/utils/mb/conversion_procs/utf8_and_gbk/Makefile	2002-08-21 17:33:55.000000000 -0400
+++ postgresql-7.4.19-new/src/backend/utils/mb/conversion_procs/utf8_and_gbk/Makefile	2008-01-15 10:55:01.000000000 -0500
@@ -3,6 +3,9 @@
 # $Id: Makefile,v 1.2 2002/08/21 21:33:55 momjian Exp $
 #
 #-------------------------------------------------------------------------
+
+DLTYPE = module
+
 subdir = src/backend/utils/mb/conversion_procs/utf8_and_gbk
 top_builddir = ../../../../../..
 include $(top_builddir)/src/Makefile.global
--- postgresql-7.4.19/src/backend/utils/mb/conversion_procs/utf8_and_iso8859/Makefile	2002-08-21 17:33:55.000000000 -0400
+++ postgresql-7.4.19-new/src/backend/utils/mb/conversion_procs/utf8_and_iso8859/Makefile	2008-01-15 10:55:01.000000000 -0500
@@ -3,6 +3,9 @@
 # $Id: Makefile,v 1.2 2002/08/21 21:33:55 momjian Exp $
 #
 #-------------------------------------------------------------------------
+
+DLTYPE = module
+
 subdir = src/backend/utils/mb/conversion_procs/utf8_and_iso8859
 top_builddir = ../../../../../..
 include $(top_builddir)/src/Makefile.global
--- postgresql-7.4.19/src/backend/utils/mb/conversion_procs/utf8_and_iso8859_1/Makefile	2002-08-21 17:33:55.000000000 -0400
+++ postgresql-7.4.19-new/src/backend/utils/mb/conversion_procs/utf8_and_iso8859_1/Makefile	2008-01-15 10:55:01.000000000 -0500
@@ -3,6 +3,9 @@
 # $Id: Makefile,v 1.2 2002/08/21 21:33:55 momjian Exp $
 #
 #-------------------------------------------------------------------------
+
+DLTYPE = module
+
 subdir = src/backend/utils/mb/conversion_procs/utf8_and_iso8859_1
 top_builddir = ../../../../../..
 include $(top_builddir)/src/Makefile.global
--- postgresql-7.4.19/src/backend/utils/mb/conversion_procs/utf8_and_johab/Makefile	2002-08-21 17:33:55.000000000 -0400
+++ postgresql-7.4.19-new/src/backend/utils/mb/conversion_procs/utf8_and_johab/Makefile	2008-01-15 10:55:01.000000000 -0500
@@ -3,6 +3,9 @@
 # $Id: Makefile,v 1.2 2002/08/21 21:33:55 momjian Exp $
 #
 #-------------------------------------------------------------------------
+
+DLTYPE = module
+
 subdir = src/backend/utils/mb/conversion_procs/utf8_and_johab
 top_builddir = ../../../../../..
 include $(top_builddir)/src/Makefile.global
--- postgresql-7.4.19/src/backend/utils/mb/conversion_procs/utf8_and_sjis/Makefile	2002-08-21 17:33:55.000000000 -0400
+++ postgresql-7.4.19-new/src/backend/utils/mb/conversion_procs/utf8_and_sjis/Makefile	2008-01-15 10:55:01.000000000 -0500
@@ -3,6 +3,9 @@
 # $Id: Makefile,v 1.2 2002/08/21 21:33:55 momjian Exp $
 #
 #-------------------------------------------------------------------------
+
+DLTYPE = module
+
 subdir = src/backend/utils/mb/conversion_procs/utf8_and_sjis
 top_builddir = ../../../../../..
 include $(top_builddir)/src/Makefile.global
--- postgresql-7.4.19/src/backend/utils/mb/conversion_procs/utf8_and_tcvn/Makefile	2002-08-21 17:33:55.000000000 -0400
+++ postgresql-7.4.19-new/src/backend/utils/mb/conversion_procs/utf8_and_tcvn/Makefile	2008-01-15 10:55:01.000000000 -0500
@@ -3,6 +3,9 @@
 # $Id: Makefile,v 1.2 2002/08/21 21:33:55 momjian Exp $
 #
 #-------------------------------------------------------------------------
+
+DLTYPE = module
+
 subdir = src/backend/utils/mb/conversion_procs/utf8_and_tcvn
 top_builddir = ../../../../../..
 include $(top_builddir)/src/Makefile.global
--- postgresql-7.4.19/src/backend/utils/mb/conversion_procs/utf8_and_uhc/Makefile	2002-08-21 17:33:55.000000000 -0400
+++ postgresql-7.4.19-new/src/backend/utils/mb/conversion_procs/utf8_and_uhc/Makefile	2008-01-15 10:55:01.000000000 -0500
@@ -3,6 +3,9 @@
 # $Id: Makefile,v 1.2 2002/08/21 21:33:55 momjian Exp $
 #
 #-------------------------------------------------------------------------
+
+DLTYPE = module
+
 subdir = src/backend/utils/mb/conversion_procs/utf8_and_uhc
 top_builddir = ../../../../../..
 include $(top_builddir)/src/Makefile.global
--- postgresql-7.4.19/src/backend/utils/mb/conversion_procs/utf8_and_win1250/Makefile	2002-08-21 17:33:55.000000000 -0400
+++ postgresql-7.4.19-new/src/backend/utils/mb/conversion_procs/utf8_and_win1250/Makefile	2008-01-15 10:55:01.000000000 -0500
@@ -3,6 +3,9 @@
 # $Id: Makefile,v 1.2 2002/08/21 21:33:55 momjian Exp $
 #
 #-------------------------------------------------------------------------
+
+DLTYPE = module
+
 subdir = src/backend/utils/mb/conversion_procs/utf8_and_win1250
 top_builddir = ../../../../../..
 include $(top_builddir)/src/Makefile.global
--- postgresql-7.4.19/src/backend/utils/mb/conversion_procs/utf8_and_win1256/Makefile	2002-08-21 17:33:55.000000000 -0400
+++ postgresql-7.4.19-new/src/backend/utils/mb/conversion_procs/utf8_and_win1256/Makefile	2008-01-15 10:55:01.000000000 -0500
@@ -3,6 +3,9 @@
 # $Id: Makefile,v 1.2 2002/08/21 21:33:55 momjian Exp $
 #
 #-------------------------------------------------------------------------
+
+DLTYPE = module
+
 subdir = src/backend/utils/mb/conversion_procs/utf8_and_win1256
 top_builddir = ../../../../../..
 include $(top_builddir)/src/Makefile.global
--- postgresql-7.4.19/src/backend/utils/mb/conversion_procs/utf8_and_win874/Makefile	2002-08-21 17:33:55.000000000 -0400
+++ postgresql-7.4.19-new/src/backend/utils/mb/conversion_procs/utf8_and_win874/Makefile	2008-01-15 10:55:01.000000000 -0500
@@ -3,6 +3,9 @@
 # $Id: Makefile,v 1.2 2002/08/21 21:33:55 momjian Exp $
 #
 #-------------------------------------------------------------------------
+
+DLTYPE = module
+
 subdir = src/backend/utils/mb/conversion_procs/utf8_and_win874
 top_builddir = ../../../../../..
 include $(top_builddir)/src/Makefile.global
--- postgresql-7.4.19/src/backend/utils/misc/postgresql.conf.sample	2006-05-21 16:11:58.000000000 -0400
+++ postgresql-7.4.19-new/src/backend/utils/misc/postgresql.conf.sample	2008-01-15 10:55:01.000000000 -0500
@@ -27,7 +27,7 @@
 
 # - Connection Settings -
 
-#tcpip_socket = false
+tcpip_socket = true
 #max_connections = 100
 	# note: increasing max_connections costs about 500 bytes of shared
 	# memory per connection slot, in addition to costs from shared_buffers
@@ -43,7 +43,7 @@
 # - Security & Authentication -
 
 #authentication_timeout = 60	# 1-600, in seconds
-#ssl = false
+ssl = false
 #password_encryption = true
 #krb_server_keyfile = ''
 #db_user_namespace = false
--- postgresql-7.4.19/src/bin/initdb/initdb.sh	2004-05-05 12:09:56.000000000 -0400
+++ postgresql-7.4.19-new/src/bin/initdb/initdb.sh	2008-01-15 10:55:01.000000000 -0500
@@ -123,20 +123,20 @@
 # their trees to backup places, so $bindir might be inaccurate.
 
 if [ x"$self_path" != x"" ] \
-  && [ -x "$self_path/postgres" ] \
-  && [ x"`$self_path/postgres -V 2>/dev/null`" = x"postgres (PostgreSQL) $VERSION" ]
+  && [ -x "$self_path/postgres-7.4" ] \
+  && [ x"`$self_path/postgres-7.4 -V 2>/dev/null`" = x"postgres (PostgreSQL) $VERSION" ]
 then
     PGPATH=$self_path
-elif [ -x "$bindir/postgres" ]; then
-    if [ x"`$bindir/postgres -V 2>/dev/null`" = x"postgres (PostgreSQL) $VERSION" ]
+elif [ -x "$bindir/postgres-7.4" ]; then
+    if [ x"`$bindir/postgres-7.4 -V 2>/dev/null`" = x"postgres (PostgreSQL) $VERSION" ]
     then
         PGPATH=$bindir
     else
         # Maybe there was an error message?
-        errormsg=`$bindir/postgres -V 2>&1 >/dev/null`
+        errormsg=`$bindir/postgres-7.4 -V 2>&1 >/dev/null`
       (
         echo "The program "
-        echo "    $bindir/postgres"
+        echo "    $bindir/postgres-7.4"
         echo "needed by $CMDNAME does not belong to PostgreSQL version $VERSION, or"
         echo "there may be a configuration problem."
         if test x"$errormsg" != x""; then
@@ -148,7 +148,7 @@
         exit 1
     fi
 else
-    echo "The program \"postgres\" is needed by $CMDNAME but was not found in" 1>&2
+    echo "The program \"postgres-7.4\" is needed by $CMDNAME but was not found in" 1>&2
     echo "the directory \"$bindir\".  Check your installation." 1>&2
     exit 1
 fi
@@ -156,20 +156,20 @@
 
 # Now we can assume that 'pg_id' belongs to the same version as the
 # verified 'postgres' in the same directory.
-if [ ! -x "$PGPATH/pg_id" ]; then
-    echo "The program \"pg_id\" is needed by $CMDNAME but was not found in" 1>&2
+if [ ! -x "$PGPATH/pg_id-7.4" ]; then
+    echo "The program \"pg_id-7.4\" is needed by $CMDNAME but was not found in" 1>&2
     echo "the directory \"$PGPATH\".  Check your installation." 1>&2
     exit 1
 fi
 
 
-EffectiveUser=`$PGPATH/pg_id -n -u`
+EffectiveUser=`$PGPATH/pg_id-7.4 -n -u`
 if [ -z "$EffectiveUser" ]; then
     echo "$CMDNAME: could not determine current user name" 1>&2
     exit 1
 fi
 
-if [ `$PGPATH/pg_id -u` -eq 0 ]
+if [ `$PGPATH/pg_id-7.4 -u` -eq 0 ]
 then
     echo "$CMDNAME: cannot be run as root" 1>&2
     echo "Please log in (using, e.g., \"su\") as the (unprivileged) user that will" 1>&2
@@ -372,11 +372,11 @@
 
 if [ "$ENCODING" ]
 then
-	ENCODINGID=`$PGPATH/pg_encoding -b $ENCODING`
+	ENCODINGID=`$PGPATH/pg_encoding-7.4 -b $ENCODING`
 	if [ "$?" -ne 0 ]
 	then
               (
-                echo "$CMDNAME: pg_encoding failed"
+                echo "$CMDNAME: pg_encoding-7.4 failed"
                 echo "Make sure the program was installed correctly."
               ) 1>&2
                 exit 1
@@ -565,7 +565,7 @@
 do
     nbuffers=`expr $nconns '*' 5`
     TEST_OPT="$PGSQL_OPT -c shared_buffers=$nbuffers -c max_connections=$nconns"
-    if "$PGPATH"/postgres -boot -x0 $TEST_OPT template1 </dev/null >/dev/null 2>&1
+    if "$PGPATH"/postgres-7.4 -boot -x0 $TEST_OPT template1 </dev/null >/dev/null 2>&1
     then
 	break
     fi
@@ -578,7 +578,7 @@
 for nbuffers in 1000 900 800 700 600 500 400 300 200 100 50
 do
     TEST_OPT="$PGSQL_OPT -c shared_buffers=$nbuffers -c max_connections=$nconns"
-    if "$PGPATH"/postgres -boot -x0 $TEST_OPT template1 </dev/null >/dev/null 2>&1
+    if "$PGPATH"/postgres-7.4 -boot -x0 $TEST_OPT template1 </dev/null >/dev/null 2>&1
     then
 	break
     fi
@@ -639,7 +639,7 @@
   export LC_COLLATE
   export LC_CTYPE
   unset LC_ALL
-  "$PGPATH"/postgres -boot -x1 $PGSQL_OPT $BOOTSTRAP_TALK_ARG template1
+  "$PGPATH"/postgres-7.4 -boot -x1 $PGSQL_OPT $BOOTSTRAP_TALK_ARG template1
 ) \
 || exit_nicely
 
@@ -661,7 +661,7 @@
 
 $ECHO_N "initializing pg_shadow... "$ECHO_C
 
-"$PGPATH"/postgres $PGSQL_OPT template1 >/dev/null <<EOF
+"$PGPATH"/postgres-7.4 $PGSQL_OPT template1 >/dev/null <<EOF
 -- Create a trigger so that direct updates to pg_shadow will be written
 -- to the flat password/group files pg_pwd and pg_group
 CREATE TRIGGER pg_sync_pg_pwd AFTER INSERT OR UPDATE OR DELETE ON pg_shadow \
@@ -694,7 +694,7 @@
         exit_nicely
     fi
     $ECHO_N "setting password... "$ECHO_C
-    "$PGPATH"/postgres $PGSQL_OPT template1 >/dev/null <<EOF
+    "$PGPATH"/postgres-7.4 $PGSQL_OPT template1 >/dev/null <<EOF
 	ALTER USER "$POSTGRES_SUPERUSERNAME" WITH PASSWORD '$FirstPw';
 EOF
     if [ "$?" -ne 0 ]; then
@@ -710,7 +710,7 @@
 
 $ECHO_N "enabling unlimited row size for system tables... "$ECHO_C
 
-"$PGPATH"/postgres $PGSQL_OPT template1 >/dev/null <<EOF
+"$PGPATH"/postgres-7.4 $PGSQL_OPT template1 >/dev/null <<EOF
 ALTER TABLE pg_attrdef CREATE TOAST TABLE;
 ALTER TABLE pg_constraint CREATE TOAST TABLE;
 ALTER TABLE pg_database CREATE TOAST TABLE;
@@ -729,7 +729,7 @@
 
 $ECHO_N "initializing pg_depend... "$ECHO_C
 
-"$PGPATH"/postgres $PGSQL_OPT template1 >/dev/null <<EOF
+"$PGPATH"/postgres-7.4 $PGSQL_OPT template1 >/dev/null <<EOF
 -- Make PIN entries in pg_depend for all objects made so far in the tables
 -- that the dependency code handles.  This is overkill (the system doesn't
 -- really depend on having every last weird datatype, for instance)
@@ -761,7 +761,7 @@
 
 $ECHO_N "creating system views... "$ECHO_C
 
-"$PGPATH"/postgres $PGSQL_OPT template1 >/dev/null <<EOF
+"$PGPATH"/postgres-7.4 $PGSQL_OPT template1 >/dev/null <<EOF
 
 CREATE VIEW pg_user AS \
     SELECT \
@@ -1051,12 +1051,12 @@
     FROM tmp_pg_description t, pg_class c WHERE c.relname = t.classname;
 EOF
 ) \
-	| "$PGPATH"/postgres $PGSQL_OPT template1 > /dev/null || exit_nicely
+	| "$PGPATH"/postgres-7.4 $PGSQL_OPT template1 > /dev/null || exit_nicely
 echo "ok"
 
 # Create pg_conversion and support functions
 $ECHO_N "creating conversions... "$ECHO_C
-grep -v '^DROP CONVERSION' $datadir/conversion_create.sql | "$PGPATH"/postgres $PGSQL_OPT template1 > /dev/null || exit_nicely
+grep -v '^DROP CONVERSION' $datadir/conversion_create.sql | "$PGPATH"/postgres-7.4 $PGSQL_OPT template1 > /dev/null || exit_nicely
 echo "ok"
 
 # Set most system catalogs and built-in functions as world-accessible.
@@ -1076,11 +1076,11 @@
     GRANT CREATE, USAGE ON SCHEMA public TO PUBLIC;
 EOF
 ) \
-	| "$PGPATH"/postgres $PGSQL_OPT template1 > /dev/null || exit_nicely
+	| "$PGPATH"/postgres-7.4 $PGSQL_OPT template1 > /dev/null || exit_nicely
 echo "ok"
 
 $ECHO_N "creating information schema... "$ECHO_C
-"$PGPATH"/postgres $PGSQL_OPT -N template1 > /dev/null < "$datadir"/information_schema.sql || exit_nicely
+"$PGPATH"/postgres-7.4 $PGSQL_OPT -N template1 > /dev/null < "$datadir"/information_schema.sql || exit_nicely
 (
   # Format version number to format required by information schema (09.08.0007abc).
   major_version=`echo $VERSION | sed 's/^\([0-9]*\).*/00\1/;s/.*\(..\)$/\1/'`
@@ -1093,12 +1093,12 @@
 
   echo "COPY information_schema.sql_features (feature_id, feature_name, sub_feature_id, sub_feature_name, is_supported, comments) FROM '$datadir/sql_features.txt';"
 ) \
-	| "$PGPATH"/postgres $PGSQL_OPT template1 > /dev/null || exit_nicely
+	| "$PGPATH"/postgres-7.4 $PGSQL_OPT template1 > /dev/null || exit_nicely
 echo "ok"
 
 $ECHO_N "vacuuming database template1... "$ECHO_C
 
-"$PGPATH"/postgres $PGSQL_OPT template1 >/dev/null <<EOF
+"$PGPATH"/postgres-7.4 $PGSQL_OPT template1 >/dev/null <<EOF
 ANALYZE;
 VACUUM FULL FREEZE;
 EOF
@@ -1109,7 +1109,7 @@
 
 $ECHO_N "copying template1 to template0... "$ECHO_C
 
-"$PGPATH"/postgres $PGSQL_OPT template1 >/dev/null <<EOF
+"$PGPATH"/postgres-7.4 $PGSQL_OPT template1 >/dev/null <<EOF
 CREATE DATABASE template0;
 
 UPDATE pg_database SET \
@@ -1145,11 +1145,7 @@
 echo
 echo "Success. You can now start the database server using:"
 echo ""
-echo "    $PGPATH/postmaster -D $PGDATA"
-echo "or"
-# (Advertise -l option here, otherwise we have a background
-#  process writing to the terminal.)
-echo "    $PGPATH/pg_ctl -D $PGDATA -l logfile start"
+echo "    sudo @INSTPREFIX@/bin/pgsql.sh-7.4 start"
 echo
 
 exit 0
--- postgresql-7.4.19/src/bin/initlocation/initlocation.sh	2003-07-23 04:46:57.000000000 -0400
+++ postgresql-7.4.19-new/src/bin/initlocation/initlocation.sh	2008-01-15 10:55:01.000000000 -0500
@@ -163,7 +163,7 @@
     echo "You can now create a database using"
     echo "  CREATE DATABASE <name> WITH LOCATION = '$Location'"
     echo "in SQL, or"
-    echo "  createdb -D '$Location' <name>"
+    echo "  createdb-7.4 -D '$Location' <name>"
     echo "from the shell."
 fi
 echo
--- postgresql-7.4.19/src/bin/pg_ctl/pg_ctl.sh	2004-10-21 20:24:27.000000000 -0400
+++ postgresql-7.4.19-new/src/bin/pg_ctl/pg_ctl.sh	2008-01-15 10:55:01.000000000 -0500
@@ -14,6 +14,10 @@
 
 CMDNAME=`basename $0`
 
+ulimit -d 24000 >/dev/null 2>&1
+ulimit -n 512   >/dev/null 2>&1
+ulimit -s 4096  >/dev/null 2>&1
+
 help="\
 $CMDNAME is a utility to start, stop, restart, reload configuration files,
 or report the status of a PostgreSQL server.
@@ -98,20 +102,20 @@
 fi
 
 # Check if needed programs actually exist in path
-if [ -x "$self_path/postmaster" ] && [ -x "$self_path/psql" ]; then
+if [ -x "$self_path/postmaster-7.4" ] && [ -x "$self_path/psql-7.4" ]; then
     PGPATH="$self_path"
-elif [ -x "$bindir/postmaster" ] && [ -x "$bindir/psql" ]; then
+elif [ -x "$bindir/postmaster-7.4" ] && [ -x "$bindir/psql-7.4" ]; then
     PGPATH="$bindir"
 else
-    echo "The programs \"postmaster\" and \"psql\" are needed by $CMDNAME but" 1>&2
+    echo "The programs \"postmaster-7.4\" and \"psql-7.4\" are needed by $CMDNAME but" 1>&2
     echo "were not found in the directory \"$bindir\"." 1>&2
     echo "Check your installation." 1>&2
     exit 1
 fi
 
-po_path="$PGPATH/postmaster"
+po_path="$PGPATH/postmaster-7.4"
 
-if [ `$PGPATH/pg_id -u` -eq 0 ]
+if [ `$PGPATH/pg_id-7.4 -u` -eq 0 ]
 then
     echo "$CMDNAME: cannot be run as root" 1>&2
     echo "Please log in (using, e.g., \"su\") as the (unprivileged) user that will" 1>&2
@@ -397,7 +401,7 @@
 	$silence_echo $ECHO_N "waiting for postmaster to start..."$ECHO_C
 	while :
 	do
-	    if "$PGPATH/psql" -p $PGPORT -l >/dev/null 2>&1
+	    if "$PGPATH/psql-7.4" -p $PGPORT -l >/dev/null 2>&1
 	    then
 		break;
 	    else
--- postgresql-7.4.19/src/include/port/darwin.h	2001-10-28 01:26:08.000000000 -0500
+++ postgresql-7.4.19-new/src/include/port/darwin.h	2008-01-15 10:55:01.000000000 -0500
@@ -1,8 +1,6 @@
 #define __darwin__	1
 
-#if defined(__ppc__)
 #define HAS_TEST_AND_SET
-#endif
 
 #if defined(__ppc__)
 typedef unsigned int slock_t;
--- postgresql-7.4.19/src/interfaces/ecpg/compatlib/Makefile	2004-03-14 07:18:35.000000000 -0500
+++ postgresql-7.4.19-new/src/interfaces/ecpg/compatlib/Makefile	2008-01-15 10:55:01.000000000 -0500
@@ -17,6 +17,8 @@
 SO_MINOR_VERSION= 2
 
 override CPPFLAGS := -I$(top_srcdir)/src/interfaces/ecpg/include -I$(libpq_srcdir) -I$(top_srcdir)/src/include/utils $(CPPFLAGS) $(THREAD_CPPFLAGS)
+override LDFLAGS := -L../../../../src/port -L@BUILDDIR@@INSTPREFIX@@FINKPREFIX@/lib -L../ecpglib -lecpg -L../pgtypeslib -lpgtypes $(libpq) $(LDFLAGS)
+
 SHLIB_LINK = -L../ecpglib -lecpg -L../pgtypeslib -lpgtypes $(libpq) \
 	$(filter -lintl -lssl -lcrypto -lkrb5 -lcrypt -lm, $(LIBS)) $(THREAD_LIBS)
 
--- postgresql-7.4.19/src/interfaces/ecpg/ecpglib/Makefile	2005-07-16 16:39:24.000000000 -0400
+++ postgresql-7.4.19-new/src/interfaces/ecpg/ecpglib/Makefile	2008-01-15 10:55:01.000000000 -0500
@@ -17,6 +17,7 @@
 SO_MINOR_VERSION= 1
 
 override CPPFLAGS := -I$(top_srcdir)/src/interfaces/ecpg/include -I$(libpq_srcdir) $(CPPFLAGS) $(THREAD_CPPFLAGS) 
+override LDFLAGS := -L@BUILDDIR@@INSTPREFIX@@FINKPREFIX@/lib -L../pgtypeslib -lpgtypes $(libpq) -L../../../../src/port $(LDFLAGS)
 
 OBJS= execute.o typename.o descriptor.o data.o error.o prepare.o memory.o \
 	connect.o misc.o path.o
--- postgresql-7.4.19/src/makefiles/Makefile.darwin	2003-10-27 02:42:34.000000000 -0500
+++ postgresql-7.4.19-new/src/makefiles/Makefile.darwin	2008-01-15 10:55:01.000000000 -0500
@@ -1,13 +1,28 @@
 AROPT = crs
 AWK= awk
  
-DLSUFFIX = .so
-CFLAGS_SL =
+ifeq ($(DLTYPE), module)
+	DLSUFFIX := .so
 BE_DLLLIBS= -bundle_loader $(top_builddir)/src/backend/postgres
+else
+	DLSUFFIX := .dylib
+	BE_DLLLIBS=
+endif
+
+CFLAGS_SL =
+CFLAGS += -fno-common
+
+ifeq (,$(filter $(host_os), darwin1.0 darwin1.1 darwin1.2))
+	DARWIN_LINKFLAGS=
+else
+	DARWIN_LINKFLAGS=-multiply_defined suppress
+endif
  
 # Rule for building shared libs (currently used only for regression test
 # shlib ... should go away, since this is not really enough knowledge)
 %.so: %.o
-	$(CC) -bundle -o $@ $< $(BE_DLLLIBS)
+	$(CC) -bundle $(DARWIN_LINKFLAGS) -o $@ $< $(BE_DLLLIBS)
+%.dylib: %.o
+	$(CC) -dynamiclib $(DARWIN_LINKFLAGS) -o $@ $<
 
 sqlmansect = 7
--- postgresql-7.4.19/src/pl/plperl/GNUmakefile	2004-01-21 14:25:11.000000000 -0500
+++ postgresql-7.4.19-new/src/pl/plperl/GNUmakefile	2008-01-15 10:55:01.000000000 -0500
@@ -1,13 +1,13 @@
 # Makefile for PL/Perl
 # $Header: /cvsroot/pgsql/src/pl/plperl/GNUmakefile,v 1.10.6.1 2004/01/21 19:25:11 tgl Exp $
 
+DLTYPE = module
+
 subdir = src/pl/plperl
 top_builddir = ../../..
 include $(top_builddir)/src/Makefile.global
 
-ifeq ($(perl_useshrplib),true)
 shared_libperl = yes
-endif
 
 # If we don't have a shared library and the platform doesn't allow it
 # to work without, we have to skip it.
--- postgresql-7.4.19/src/pl/plpgsql/Makefile	2001-05-24 18:33:18.000000000 -0400
+++ postgresql-7.4.19-new/src/pl/plpgsql/Makefile	2008-01-15 10:55:01.000000000 -0500
@@ -8,6 +8,8 @@
 #
 #-------------------------------------------------------------------------
 
+DLTYPE = module
+
 subdir = src/pl/plpgsql
 top_builddir = ../../..
 include $(top_builddir)/src/Makefile.global
--- postgresql-7.4.19/src/pl/plpgsql/src/Makefile	2004-02-10 02:26:48.000000000 -0500
+++ postgresql-7.4.19-new/src/pl/plpgsql/src/Makefile	2008-01-15 10:55:01.000000000 -0500
@@ -6,6 +6,8 @@
 #
 #-------------------------------------------------------------------------
 
+DLTYPE = module
+
 subdir = src/pl/plpgsql/src
 top_builddir = ../../../..
 include $(top_builddir)/src/Makefile.global
@@ -20,6 +22,7 @@
 SO_MINOR_VERSION= 0
 
 override CPPFLAGS := -I$(srcdir) $(CPPFLAGS)
+override LDFLAGS := $(libpq) $(LDFLAGS)
 SHLIB_LINK = $(filter -lintl, $(LIBS)) $(BE_DLLLIBS)
 rpath :=
 
--- postgresql-7.4.19/src/pl/plpython/Makefile	2004-01-21 14:25:11.000000000 -0500
+++ postgresql-7.4.19-new/src/pl/plpython/Makefile	2008-01-15 10:55:01.000000000 -0500
@@ -1,5 +1,7 @@
 # $Header: /cvsroot/pgsql/src/pl/plpython/Makefile,v 1.11.6.1 2004/01/21 19:25:11 tgl Exp $
 
+DLTYPE = module
+
 subdir = src/pl/plpython
 top_builddir = ../../..
 include $(top_builddir)/src/Makefile.global
@@ -8,13 +10,12 @@
 # On some platforms we can only build PL/Python if libpython is a
 # shared library.  Since there is no official way to determine this,
 # we see if there is a file that is named like a shared library.
-ifneq (,$(wildcard $(python_configdir)/libpython*$(DLSUFFIX)*))
+ifneq (,$(wildcard $(python_configdir)/libpython*.dylib*))
 shared_libpython = yes
 endif
 
 # If we don't have a shared library and the platform doesn't allow it
 # to work without, we have to skip it.
-ifneq (,$(findstring yes, $(shared_libpython)$(allow_nonpic_in_shlib)))
 
 override CPPFLAGS := -I$(srcdir) $(python_includespec) $(CPPFLAGS)
 rpath :=
@@ -32,13 +33,7 @@
 all: all-lib
 
 install: all installdirs
-ifeq ($(enable_shared), yes)
 	$(INSTALL_SHLIB) $(shlib) $(DESTDIR)$(pkglibdir)/plpython$(DLSUFFIX)
-else
-	@echo "*****"; \
-	 echo "* PL/Python was not installed due to lack of shared library support."; \
-	 echo "*****"
-endif
 
 installdirs:
 	$(mkinstalldirs) $(DESTDIR)$(pkglibdir)
@@ -53,13 +48,3 @@
 installcheck:
 	PATH=$(bindir):$$PATH $(SHELL) $(srcdir)/test.sh
 
-else # can't build
-
-all:
-	@echo ""; \
-	 echo "*** Cannot build PL/Python because libpython is not a shared library." ; \
-	 echo "*** You might have to rebuild your Python installation.  Refer to"; \
-	 echo "*** the documentation for details."; \
-	 echo ""
-
-endif # can't build
--- postgresql-7.4.19/src/pl/tcl/Makefile	2004-01-21 14:25:11.000000000 -0500
+++ postgresql-7.4.19-new/src/pl/tcl/Makefile	2008-01-15 10:55:01.000000000 -0500
@@ -6,6 +6,8 @@
 #
 #-------------------------------------------------------------------------
 
+DLTYPE = module
+
 subdir = src/pl/tcl
 top_builddir = ../../..
 include $(top_builddir)/src/Makefile.global
--- postgresql-7.4.19/src/pl/tcl/modules/Makefile	2002-01-08 18:40:02.000000000 -0500
+++ postgresql-7.4.19-new/src/pl/tcl/modules/Makefile	2008-01-15 10:55:01.000000000 -0500
@@ -1,5 +1,7 @@
 # $Header: /cvsroot/pgsql/src/pl/tcl/modules/Makefile,v 1.2 2002/01/08 23:40:02 tgl Exp $
 
+DLTYPE = module
+
 subdir = src/pl/tcl/modules
 top_builddir = ../../../..
 include $(top_builddir)/src/Makefile.global
--- postgresql-7.4.19/src/template/darwin	2004-07-08 14:25:22.000000000 -0400
+++ postgresql-7.4.19-new/src/template/darwin	2008-01-15 10:55:01.000000000 -0500
@@ -1,10 +1,13 @@
-# Apple's cpp-precomp seems a tad broken, so don't use it
-# (Note: on OS X before 10.2, you might need -traditional-cpp instead)
-CC="$CC -no-cpp-precomp"
-
 # Select appropriate semaphore support
 USE_NAMED_POSIX_SEMAPHORES=1
 
+# tools/thread/thread_test must be run
+THREAD_SUPPORT=yes
+THREAD_CPPFLAGS="-D_REENTRANT -D_THREAD_SAFE -D_POSIX_PTHREAD_SEMANTICS"
+THREAD_LIBS="-lpthread"
+
+NEED_REENTRANT_FUNCS=yes
+
 THREAD_SUPPORT=yes
 THREAD_CPPFLAGS="-D_REENTRANT -D_THREAD_SAFE -D_POSIX_PTHREAD_SEMANTICS"
 THREAD_LIBS="-lpthread"
