diff --git a/src/Makefile.global.in b/src/Makefile.global.in
index a3f3d0e465c12e5660429d30288eb11c194d4e42..e5efb1eed142bf18df1628c7e7d2706a8dbe717b 100644
--- a/src/Makefile.global.in
+++ b/src/Makefile.global.in
@@ -7,7 +7,7 @@
 #
 #
 # IDENTIFICATION
-#    $Header: /cvsroot/pgsql/src/Makefile.global.in,v 1.19 1997/04/04 11:21:39 scrappy Exp $
+#    $Header: /cvsroot/pgsql/src/Makefile.global.in,v 1.20 1997/04/12 10:32:03 scrappy Exp $
 #
 # NOTES
 #    Essentially all Postgres make files include this file and use the 
@@ -227,16 +227,6 @@ DASH_N= @DASH_N@
 BACKSLASH_C= @BACKSLASH_C@ 
 
 
-##############################################################################
-#
-# Customization.
-#
-# This includes your local customizations if Makefile.custom exists
-# in the source directory.  This file doesn't exist in the original
-# distribution so that it doesn't get overwritten when you upgrade.
-ifneq ($(wildcard $(SRCDIR)/Makefile.custom), )
-include $(SRCDIR)/Makefile.custom
-endif
 
 #-------------------------------------------------------------
 # See the subdirectory template for default settings for these
@@ -251,171 +241,17 @@ CFLAGS_SL= @SHARED_LIB@
 LDFLAGS= @LDFLAGS@ @LIBS@
 DLSUFFIX= @DLSUFFIX@
 
-#----------------------------------------------------------------------
-ifeq ($(PORTNAME), BSD44_derived)
-%.so: %.o
-	$(LD) -x -r -o $<.obj $<
-	@echo building shared object $@
-	@rm -f $@.pic
-	@${AR} cq $@.pic `lorder $<.obj | tsort`
-	${RANLIB} $@.pic
-	@rm -f $@
-	$(LD) -x -Bshareable -Bforcearchive \
-	  -o $@ $@.pic
-endif
-
-#--------------------------------------------------------------------------
-
-ifeq ($(PORTNAME), aix)
-
-# MAKE_EXPORTS is required for svr4 loaders that want a file of
-# symbol names to tell them what to export/import.
-MAKE_EXPORTS= true
-
-EXPSUFF= .exp
-
-POSTGRES_EXP= $(SRCDIR)/backend/postgres$(EXPSUFF)
-
-MKLDEXPORT=$(SRCDIR)/backend/port/aix/mkldexport.sh
-
-%$(EXPSUFF):  %.o
-	$(MKLDEXPORT) $< `pwd` > $@
-
-$(POSTGRES_EXP): 
-	$(MAKE) -C $(SRCDIR)/backend postgres.exp
-
-%.so: %.o %$(EXPSUFF) $(POSTGRES_EXP)
-	@echo Making share library $@ from $*.o, $*$(EXPSUFF), and postgres.exp
-	$(LD) -H512 -T512 -o $@ -e _nostart \
-	  -bI:$(POSTGRES_EXP) -bE:$*$(EXPSUFF) \
-	  $*.o @MATH_LIB@ -lc 2>/dev/null
-endif
-
-#---------------------------------------------------------------------------
-
-ifeq ($(PORTNAME), alpha)
-%.so:  %.o
-	$(LD) -shared -expect_unresolved '*' -o $@ $<
-endif
-
-#--------------------------------------------------------------------------
-
-ifeq ($(PORTNAME), dgux)
-%.so: %.o
-	$(CC) -shared -o $@ $<
-endif
-
-#----------------------------------------------------------------------------
-
-ifeq ($(PORTNAME), hpux)
-
-#ifdef ENFORCE_ALIGNMENT
-#   CFLAGS_BE= -DNOFIXADE
-#else
-#   HPUX_VERS:= $(shell uname -r)
-#   HPUX_MAJOR= ${HPUX_VERS:R:E}
-#   HPUX_MINOR= ${HPUX_VERS:E}
-#   ifeq ($(HPUX_MAJOR), 08)
-#      CFLAGS_BE+= +u -DHP_S500_ALIGN
-#      LDFLAGS_BE+= +u
-#   else
-#   ifeq ($(HPUX_MAJOR), 09)
-#      ifeq ($(CC), cc)
-#         CFLAGS_BE+= +u4 
-#         LDFLAGS_BE+= +u4
-#      endif
-#   endif
-#   endif
-#endif
-
-%.sl: %.o
-	$(LD) -b -o $@ $<
-
-endif
-
-#--------------------------------------------------------------------------
-
-ifeq ($(PORTNAME), i386_solaris)
-%.so: %.o
-	$(LD) -G -Bdynamic -o $@ $<
-endif
-
-#----------------------------------------------------------------------------
-
-ifeq ($(PORTNAME), irix5)
-
-# RANLIB is not used on IRIX 5
-RANLIB= touch
-
-%.so: %.o
-	$(LD) -G -Bdynamic -o $@ $< $(LDFLAGS)
-
-endif
-
-#---------------------------------------------------------------------------
-
-ifeq ($(PORTNAME), linux)
-ifdef LINUX_ELF
-LDFLAGS+= -rdynamic
-endif
-MK_NO_LORDER= true
-
-%.so: %.o
-	$(CC) -shared -o $@ $<
-
-endif
-
-#---------------------------------------------------------------------------
-
-ifeq ($(PORTNAME), sunos4)
-%.so: %.o
-	$(LD) -dc -dp -Bdynamic -o $@ $<
-endif
-
-#----------------------------------------------------------------------------
-
-ifeq ($(PORTNAME), sparc_solaris)
-%.so: %.o
-	$(LD) -G -Bdynamic -o $@ $<
-endif
-
-#-----------------------------------------------------------------------------
-
-ifeq ($(PORTNAME), svr4)
-# MAKE_EXPORTS is required for svr4 loaders that want a file of
-# symbol names to tell them what to export/import.
-MAKE_EXPORTS= true
-
-LDFLAGS+= /usr/ucblib/libucb.a -LD-Blargedynsym
-
-%.so: %.o
-	$(LD) -G -Bdynamic -o $@ $<
-
-endif
-
-#---------------------------------------------------------------------------
-
-ifeq ($(PORTNAME), ultrix4)
-# install creates intermediate directories
-NO_BEFOREINSTL= true
-endif
-
-
-#-----------------------------------------------------------------------------
+include $(SRCDIR)/Makefile.port
 
+##############################################################################
 #
-#	The univel port is almost guaranteed NOT to work yet.
+# Customization.
 #
-ifeq ($(PORTNAME), univel)
-# MAKE_EXPORTS is required for svr4 loaders that want a file of
-# symbol names to tell them what to export/import.
-#MAKE_EXPORTS= true
-
-%.so: %.o
-	$(LD) -G -Bdynamic -o $@ $<
-
-INSTALL= /usr/ucb/install
-
+# This includes your local customizations if Makefile.custom exists
+# in the source directory.  This file doesn't exist in the original
+# distribution so that it doesn't get overwritten when you upgrade.
+ifneq ($(wildcard $(SRCDIR)/Makefile.custom), )
+include $(SRCDIR)/Makefile.custom
 endif
 
 # This goes here so that customization in Makefile.custom is effective
diff --git a/src/makefiles/Makefile.BSD44_derived b/src/makefiles/Makefile.BSD44_derived
new file mode 100644
index 0000000000000000000000000000000000000000..1c17504605c97470026a0c514fac0a74f7586ea7
--- /dev/null
+++ b/src/makefiles/Makefile.BSD44_derived
@@ -0,0 +1,9 @@
+%.so: %.o
+	$(LD) -x -r -o $<.obj $<
+	@echo building shared object $@
+	@rm -f $@.pic
+	@${AR} cq $@.pic `lorder $<.obj | tsort`
+	${RANLIB} $@.pic
+	@rm -f $@
+	$(LD) -x -Bshareable -Bforcearchive \
+	  -o $@ $@.pic
diff --git a/src/makefiles/Makefile.aix b/src/makefiles/Makefile.aix
new file mode 100644
index 0000000000000000000000000000000000000000..acd10c2fbc91e280290a0382ce3c73929c6b7ba8
--- /dev/null
+++ b/src/makefiles/Makefile.aix
@@ -0,0 +1,21 @@
+# MAKE_EXPORTS is required for svr4 loaders that want a file of
+# symbol names to tell them what to export/import.
+MAKE_EXPORTS= true
+
+EXPSUFF= .exp
+
+POSTGRES_EXP= $(SRCDIR)/backend/postgres$(EXPSUFF)
+
+MKLDEXPORT=$(SRCDIR)/backend/port/aix/mkldexport.sh
+
+%$(EXPSUFF):  %.o
+	$(MKLDEXPORT) $< `pwd` > $@
+
+$(POSTGRES_EXP): 
+	$(MAKE) -C $(SRCDIR)/backend postgres.exp
+
+%.so: %.o %$(EXPSUFF) $(POSTGRES_EXP)
+	@echo Making share library $@ from $*.o, $*$(EXPSUFF), and postgres.exp
+	$(LD) -H512 -T512 -o $@ -e _nostart \
+	  -bI:$(POSTGRES_EXP) -bE:$*$(EXPSUFF) \
+	  $*.o @MATH_LIB@ -lc 2>/dev/null
diff --git a/src/makefiles/Makefile.alpha b/src/makefiles/Makefile.alpha
new file mode 100644
index 0000000000000000000000000000000000000000..a9e8e948ec66e20b70f72c939da329311329bb83
--- /dev/null
+++ b/src/makefiles/Makefile.alpha
@@ -0,0 +1,2 @@
+%.so:  %.o
+	$(LD) -shared -expect_unresolved '*' -o $@ $<
diff --git a/src/makefiles/Makefile.dgux b/src/makefiles/Makefile.dgux
new file mode 100644
index 0000000000000000000000000000000000000000..21a43c0f15a46f2704ddc03cd12c73b2c9961216
--- /dev/null
+++ b/src/makefiles/Makefile.dgux
@@ -0,0 +1,2 @@
+%.so: %.o
+	$(CC) -shared -o $@ $<
diff --git a/src/makefiles/Makefile.hpux b/src/makefiles/Makefile.hpux
new file mode 100644
index 0000000000000000000000000000000000000000..9b530f76815e5966c49adc6aca8eaabeee25fe3d
--- /dev/null
+++ b/src/makefiles/Makefile.hpux
@@ -0,0 +1,23 @@
+
+#ifdef ENFORCE_ALIGNMENT
+#   CFLAGS_BE= -DNOFIXADE
+#else
+#   HPUX_VERS:= $(shell uname -r)
+#   HPUX_MAJOR= ${HPUX_VERS:R:E}
+#   HPUX_MINOR= ${HPUX_VERS:E}
+#   ifeq ($(HPUX_MAJOR), 08)
+#      CFLAGS_BE+= +u -DHP_S500_ALIGN
+#      LDFLAGS_BE+= +u
+#   else
+#   ifeq ($(HPUX_MAJOR), 09)
+#      ifeq ($(CC), cc)
+#         CFLAGS_BE+= +u4 
+#         LDFLAGS_BE+= +u4
+#      endif
+#   endif
+#   endif
+#endif
+
+%.sl: %.o
+	$(LD) -b -o $@ $<
+
diff --git a/src/makefiles/Makefile.i386_solaris b/src/makefiles/Makefile.i386_solaris
new file mode 100644
index 0000000000000000000000000000000000000000..b67d7ed5e2126591c10893a194ab059186120d9f
--- /dev/null
+++ b/src/makefiles/Makefile.i386_solaris
@@ -0,0 +1,2 @@
+%.so: %.o
+	$(LD) -G -Bdynamic -o $@ $<
diff --git a/src/makefiles/Makefile.irix5 b/src/makefiles/Makefile.irix5
new file mode 100644
index 0000000000000000000000000000000000000000..e0f705d051e1a6a156a83cc5a1eace8eb795c91b
--- /dev/null
+++ b/src/makefiles/Makefile.irix5
@@ -0,0 +1,7 @@
+
+# RANLIB is not used on IRIX 5
+RANLIB= touch
+
+%.so: %.o
+	$(LD) -G -Bdynamic -o $@ $< $(LDFLAGS)
+
diff --git a/src/makefiles/Makefile.linux b/src/makefiles/Makefile.linux
new file mode 100644
index 0000000000000000000000000000000000000000..21df0c8a23a93b343b78db32459aebb1229af1e7
--- /dev/null
+++ b/src/makefiles/Makefile.linux
@@ -0,0 +1,8 @@
+ifdef LINUX_ELF
+LDFLAGS+= -rdynamic
+endif
+MK_NO_LORDER= true
+
+%.so: %.o
+	$(CC) -shared -o $@ $<
+
diff --git a/src/makefiles/Makefile.sparc_solaris b/src/makefiles/Makefile.sparc_solaris
new file mode 100644
index 0000000000000000000000000000000000000000..b67d7ed5e2126591c10893a194ab059186120d9f
--- /dev/null
+++ b/src/makefiles/Makefile.sparc_solaris
@@ -0,0 +1,2 @@
+%.so: %.o
+	$(LD) -G -Bdynamic -o $@ $<
diff --git a/src/makefiles/Makefile.sunos4 b/src/makefiles/Makefile.sunos4
new file mode 100644
index 0000000000000000000000000000000000000000..3bcdf0806c5c02b0178d8cdc5b723ca2bae90f67
--- /dev/null
+++ b/src/makefiles/Makefile.sunos4
@@ -0,0 +1,2 @@
+%.so: %.o
+	$(LD) -dc -dp -Bdynamic -o $@ $<
diff --git a/src/makefiles/Makefile.svr4 b/src/makefiles/Makefile.svr4
new file mode 100644
index 0000000000000000000000000000000000000000..9c9e5b3e5af76e97a36a54ef58c3ca81c00ce787
--- /dev/null
+++ b/src/makefiles/Makefile.svr4
@@ -0,0 +1,9 @@
+# MAKE_EXPORTS is required for svr4 loaders that want a file of
+# symbol names to tell them what to export/import.
+MAKE_EXPORTS= true
+
+LDFLAGS+= /usr/ucblib/libucb.a -LD-Blargedynsym
+
+%.so: %.o
+	$(LD) -G -Bdynamic -o $@ $<
+
diff --git a/src/makefiles/Makefile.ultrix4 b/src/makefiles/Makefile.ultrix4
new file mode 100644
index 0000000000000000000000000000000000000000..cf46e90819b76cc5f0e5c0e133cf046cfce77220
--- /dev/null
+++ b/src/makefiles/Makefile.ultrix4
@@ -0,0 +1,2 @@
+# install creates intermediate directories
+NO_BEFOREINSTL= true
diff --git a/src/makefiles/Makefile.univel b/src/makefiles/Makefile.univel
new file mode 100644
index 0000000000000000000000000000000000000000..3bfc5c0799e8fe0b60890d92a0482e0ec3de0e13
--- /dev/null
+++ b/src/makefiles/Makefile.univel
@@ -0,0 +1,12 @@
+#
+#	The univel port is almost guaranteed NOT to work yet.
+#
+# MAKE_EXPORTS is required for svr4 loaders that want a file of
+# symbol names to tell them what to export/import.
+#MAKE_EXPORTS= true
+
+%.so: %.o
+	$(LD) -G -Bdynamic -o $@ $<
+
+INSTALL= /usr/ucb/install
+