From 6d98d3737ab2fc6883c42885b128d4ace281db6d Mon Sep 17 00:00:00 2001
From: Tom Lane <tgl@sss.pgh.pa.us>
Date: Mon, 19 Oct 1998 00:00:51 +0000
Subject: [PATCH] Centralized shared-library build knowledge in a new file,
 src/Makefile.shlib.  Updated all the makefiles that try to build shlibs to
 include that file instead of having duplicate (and mostly incomplete) copies
 of shared-library options.  It works on HPUX, a lot better than it did before
 in fact, but there's a chance I broke some other platforms. At least now you
 only have to fix one place not six...

---
 src/Makefile.global.in                 |   9 +-
 src/Makefile.shlib                     | 180 +++++++++++++++++++++++++
 src/interfaces/ecpg/lib/Makefile.in    | 132 +++++-------------
 src/interfaces/libpgtcl/Makefile.in    | 137 +++----------------
 src/interfaces/libpq++/Makefile.in     | 144 ++------------------
 src/interfaces/libpq/Makefile.in       | 120 +----------------
 src/interfaces/odbc/GNUmakefile.in     |  73 +++-------
 src/interfaces/odbc/Makefile.global.in |   9 +-
 src/pl/plpgsql/src/Makefile.in         | 121 ++++-------------
 9 files changed, 300 insertions(+), 625 deletions(-)
 create mode 100644 src/Makefile.shlib

diff --git a/src/Makefile.global.in b/src/Makefile.global.in
index 2492c9394a9..8330ab23d79 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.51 1998/10/15 15:58:12 momjian Exp $
+#    $Header: /cvsroot/pgsql/src/Makefile.global.in,v 1.52 1998/10/19 00:00:40 tgl Exp $
 #
 # NOTES
 #    Essentially all Postgres make files include this file and use the 
@@ -206,6 +206,13 @@ LDFLAGS= @LDFLAGS@ @LIBS@
 DLSUFFIX= @DLSUFFIX@
 LN_S= @LN_S@
 
+##############################################################################
+#
+# Additional platform-specific settings
+#
+
+PORTNAME= @PORTNAME@
+
 include $(SRCDIR)/Makefile.port
 
 ##############################################################################
diff --git a/src/Makefile.shlib b/src/Makefile.shlib
new file mode 100644
index 00000000000..d1557f0128b
--- /dev/null
+++ b/src/Makefile.shlib
@@ -0,0 +1,180 @@
+#-------------------------------------------------------------------------
+#
+# Makefile.shlib
+#    Common rules for building shared libraries
+#
+# Copyright (c) 1998, Regents of the University of California
+#
+# IDENTIFICATION
+#    $Header: /cvsroot/pgsql/src/Makefile.shlib,v 1.1 1998/10/19 00:00:40 tgl Exp $
+#
+#-------------------------------------------------------------------------
+
+# This file should be included by any Postgres module Makefile that wants
+# to build a shared library (if possible for the current platform).
+# A static library is also built from the same object files.
+# RESTRICTION: only one library can be built per makefile...
+
+# Before including this file, the module Makefile must define these variables:
+# NAME				Name of library to build (no suffix nor "lib" prefix)
+# SO_MAJOR_VERSION	Major version number to use for shared library
+# SO_MINOR_VERSION	Minor version number to use for shared library
+# OBJS				List of object files to include in library
+# SHLIB_LINK		If shared library relies on other libraries, additional
+#					stuff to put in its link command
+# (If you want a patchlevel, include it in SO_MINOR_VERSION, eg, "6.2".)
+#
+# The module Makefile must also include $(SRCDIR)/Makefile.global before
+# including this file (Makefile.global sets PORTNAME and other needed symbols).
+#
+# The first rule in this file is a rule for "all", which causes both the
+# static and shared libraries to be built (as well as all the object files).
+# If you have other files that need to be made before building object files
+# and libraries, put another rule for "all" before you include this file.
+#
+# Your install rule should look like
+#
+#	install: install-headers install-lib $(install-shlib-dep)
+#
+# where install-headers is only needed if you have header files to install
+# (and, of course, it has to be provided by your makefile).  The rules
+# install-lib and install-shlib are provided by this makefile --- they
+# automatically install the plain and shared libraries into $(LIBDIR).
+# install-shlib-dep is a variable that expands to install-shlib if the
+# shared library needs to be installed, empty if not.
+#
+# Got that?  Look at src/interfaces/libpq/Makefile.in for an example.
+
+
+# shlib and install-shlib-dep default to empty, and stay that way if we're
+# on a platform where we don't know how to build a shared library.
+shlib := 
+install-shlib-dep :=
+
+# For each platform we support shlibs on, set shlib and install-shlib-dep,
+# and update flags as needed to build a shared lib.  Note we depend on
+# Makefile.global (or really Makefile.port) to supply DLSUFFIX and other
+# symbols.
+
+ifeq ($(PORTNAME), bsd)
+  ifdef BSD_SHLIB
+    install-shlib-dep	:= install-shlib
+    shlib				:= lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
+    LDFLAGS_SL			:= -x -Bshareable -Bforcearchive
+    CFLAGS				+= $(CFLAGS_SL)
+  endif
+endif
+
+ifeq ($(PORTNAME), bsdi)
+  ifdef BSD_SHLIB
+    ifeq ($(DLSUFFIX), .so)
+      install-shlib-dep := install-shlib
+      shlib				:= lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
+      LDFLAGS_SL		+= -shared
+      CFLAGS			+= $(CFLAGS_SL)
+    endif
+    ifeq ($(DLSUFFIX), .o)
+      install-shlib-dep	:= install-shlib
+      shlib				:= lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
+      LD				:= shlicc
+      LDFLAGS_SL	 	+= -O -r
+      CFLAGS			+= $(CFLAGS_SL)
+    endif
+  endif
+endif
+
+ifeq ($(PORTNAME), hpux)
+  install-shlib-dep	:= install-shlib
+# HPUX doesn't believe in version numbers for shlibs
+  shlib				:= lib$(NAME)$(DLSUFFIX)
+  LDFLAGS_SL		:= -b
+  CFLAGS			+= $(CFLAGS_SL)
+endif
+
+ifeq ($(PORTNAME), linux)
+  install-shlib-dep	:= install-shlib
+  shlib				:= lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
+  LDFLAGS_SL		:= -shared -soname $(shlib)
+  CFLAGS			+= $(CFLAGS_SL)
+endif
+
+ifeq ($(PORTNAME), solaris_i386)
+  install-shlib-dep	:= install-shlib
+  shlib				:= lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
+  LDFLAGS_SL		:= -G
+  CFLAGS			+= $(CFLAGS_SL)
+endif
+
+ifeq ($(PORTNAME), solaris_sparc)
+  install-shlib-dep	:= install-shlib
+  shlib				:= lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
+  LDFLAGS_SL		:= -G
+  CFLAGS			+= $(CFLAGS_SL)
+endif
+
+ifeq ($(PORTNAME), svr4)
+  install-shlib-dep	:= install-shlib
+  shlib				:= lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
+  LDFLAGS_SL		:= -G
+  CFLAGS			+= $(CFLAGS_SL)
+endif
+
+ifeq ($(PORTNAME), univel)
+  install-shlib-dep	:= install-shlib
+  shlib				:= lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
+  LDFLAGS_SL		:= -G -z text
+  CFLAGS			+= $(CFLAGS_SL)
+  ifeq ($(CXX), CC)
+    CXXFLAGS += -Xw
+    COMPILE.cc = $(CXX) $(CXXFLAGS:ll,alloca=ll) $(CPPFLAGS) $(TARGET_ARCH) -c
+  endif
+endif
+
+ifeq ($(PORTNAME), unixware)
+  install-shlib-dep	:= install-shlib
+  shlib				:= lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
+  LDFLAGS_SL		:= -G -z text
+  CFLAGS			+= $(CFLAGS_SL)
+  ifeq ($(CXX), CC)
+    CXXFLAGS += -Xw
+    COMPILE.cc = $(CXX) $(CXXFLAGS:ll,alloca=ll) $(CPPFLAGS) $(TARGET_ARCH) -c
+  endif
+endif
+
+
+# Default target definition.  Note shlib is empty if not building a shlib.
+
+all: lib$(NAME).a $(shlib)
+
+# Rules to build regular and shared libraries
+
+lib$(NAME).a: $(OBJS)
+ifdef MK_NO_LORDER
+	$(AR) $(AROPT) $@ $(OBJS) 
+else
+	$(AR) $(AROPT) $@ `lorder $(OBJS) | tsort`
+endif
+	$(RANLIB) $@
+
+$(shlib): $(OBJS)
+	$(LD) $(LDFLAGS_SL) -o $@ $(OBJS) $(SHLIB_LINK)
+
+# Rules to install regular and shared libraries
+
+.PHONY: all install-lib install-shlib
+
+install-lib: lib$(NAME).a
+	$(INSTALL) $(INSTL_LIB_OPTS) lib$(NAME).a $(LIBDIR)/lib$(NAME).a
+
+install-shlib: $(shlib)
+	$(INSTALL) $(INSTL_SHLIB_OPTS) $(shlib) $(LIBDIR)/$(shlib)
+	if [ "$(shlib)" != "lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)" ]; then \
+		cd $(LIBDIR); \
+		rm -f lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION); \
+		$(LN_S) $(shlib) lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION); \
+	fi
+	if [ "$(shlib)" != "lib$(NAME)$(DLSUFFIX)" ]; then \
+		cd $(LIBDIR); \
+		rm -f lib$(NAME)$(DLSUFFIX); \
+		$(LN_S) $(shlib) lib$(NAME)$(DLSUFFIX); \
+	fi
diff --git a/src/interfaces/ecpg/lib/Makefile.in b/src/interfaces/ecpg/lib/Makefile.in
index b04a1e7cb65..88d39846deb 100644
--- a/src/interfaces/ecpg/lib/Makefile.in
+++ b/src/interfaces/ecpg/lib/Makefile.in
@@ -1,124 +1,52 @@
+#-------------------------------------------------------------------------
+#
+# Makefile
+#    Makefile for ecpg library
+#
+# Copyright (c) 1994, Regents of the University of California
+#
+# IDENTIFICATION
+#    $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/Makefile.in,v 1.38 1998/10/19 00:00:40 tgl Exp $
+#
+#-------------------------------------------------------------------------
+
 NAME= ecpg
 SO_MAJOR_VERSION= 2
-SO_MINOR_VERSION= 6
-SO_PATCHLEVEL= 2
+SO_MINOR_VERSION= 6.2
 
 SRCDIR= @top_srcdir@
-
 include $(SRCDIR)/Makefile.global
 
-PQ_INCLUDE=-I$(SRCDIR)/interfaces/libpq
-
-PORTNAME=@PORTNAME@
+CFLAGS+= -I../include -I$(SRCDIR)/interfaces/libpq
 
 ifdef KRBVERS
 CFLAGS+= $(KRBFLAGS)
 endif
 
-# Shared library stuff
-shlib := 
-install-shlib-dep :=
+OBJS= ecpglib.o typename.o
 
-ifeq ($(PORTNAME), linux)
-  LINUX_ELF=@LINUX_ELF@
-  ifdef LINUX_ELF
-    install-shlib-dep := install-shlib
-    shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION).$(SO_PATCHLEVEL)
-    LDFLAGS_SL = -shared -soname lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)
-  endif
-endif
+SHLIB_LINK= -L../../libpq -lpq
 
-ifeq ($(PORTNAME), bsd)
-  ifdef BSD_SHLIB
-    install-shlib-dep := install-shlib
-    shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION).$(SO_PATCHLEVEL)
-    LDFLAGS_SL = -x -Bshareable -Bforcearchive
-    CFLAGS += $(CFLAGS_SL)
-  endif
-endif
+# Shared library stuff, also default 'all' target
+include $(SRCDIR)/Makefile.shlib
 
-ifeq ($(PORTNAME), solaris_sparc)
-  install-shlib-dep := install-shlib
-  shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION).$(SO_PATCHLEVEL)
-  LDFLAGS_SL = -G
-  CFLAGS += $(CFLAGS_SL)
-endif
 
-ifeq ($(PORTNAME), solaris_i386)
-  install-shlib-dep := install-shlib
-  shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION).$(SO_PATCHLEVEL)
-  LDFLAGS_SL = -G
-  CFLAGS += $(CFLAGS_SL)
-endif
-
-ifeq ($(PORTNAME), svr4)
-  install-shlib-dep := install-shlib
-  shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION).$(SO_PATCHLEVEL)
-  LDFLAGS_SL = -G
-  CFLAGS += $(CFLAGS_SL)
-endif
-
-ifeq ($(PORTNAME), univel)
-  install-shlib-dep := install-shlib
-  shlib := lib$(NAME)$(DLSUFFIX).1
-  LDFLAGS_SL = -G -z text
-  CFLAGS += $(CFLAGS_SL)
-endif
-
-ifeq ($(PORTNAME), unixware)
-  install-shlib-dep := install-shlib
-  shlib := lib$(NAME)$(DLSUFFIX).1
-  LDFLAGS_SL = -G -z text
-  CFLAGS += $(CFLAGS_SL)
-endif
+.PHONY: install
 
-ifeq ($(PORTNAME), hpux)
-  install-shlib-dep	:= install-shlib
-  shlib				:= lib$(NAME).sl
-  LDFLAGS_SL		:= -b
-  CFLAGS			+= $(CFLAGS_SL)
-endif
+install: install-lib $(install-shlib-dep)
 
-all: lib$(NAME).a $(shlib)
+# Handmade dependencies in case make depend not done
+ecpglib.o : ecpglib.c ../include/ecpglib.h ../include/ecpgtype.h
+typename.o : typename.c ../include/ecpgtype.h
 
-$(shlib): ecpglib.o typename.o
-	$(LD) $(LDFLAGS_SL) -o $@ ecpglib.o typename.o
 
+.PHONY: clean
 clean:
-	rm -f *.o *.a core a.out *~ $(shlib) lib$(NAME)$(DLSUFFIX)
-
-dep depend:
-
-.PHONY: install install-libecpg install-shlib
-
-install: install-libecpg $(install-shlib-dep)
-
-install-libecpg: lib$(NAME).a
-	$(INSTALL) $(INSTL_LIB_OPTS) lib$(NAME).a $(LIBDIR)/lib$(NAME).a
+	rm -f lib$(NAME).a $(shlib) $(OBJS)
 
-install-shlib: $(shlib)
-	$(INSTALL) $(INSTL_SHLIB_OPTS) $(shlib) $(LIBDIR)/$(shlib)
-	if [ "$(shlib)" != "lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)" ]; then \
-		cd $(LIBDIR); \
-		rm -f lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION); \
-		$(LN_S) $(shlib) lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION); \
-	fi
-	if [ "$(shlib)" != "lib$(NAME)$(DLSUFFIX)" ]; then \
-		cd $(LIBDIR); \
-		rm -f lib$(NAME)$(DLSUFFIX); \
-		$(LN_S) $(shlib) lib$(NAME)$(DLSUFFIX); \
-	fi
+depend dep:
+	$(CC) -MM $(CFLAGS) *.c >depend
 
-
-uninstall::
-	rm -f $(LIBDIR)/lib$(NAME).a $(LIBDIR)/$(shlib)
-	rm -f $(LIBDIR)/lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)
-	rm -f $(LIBDIR)/lib$(NAME)$(DLSUFFIX)
-
-# Rules that do something
-lib$(NAME).a : lib$(NAME).a(ecpglib.o) lib$(NAME).a(typename.o)
-
-ecpglib.o : ecpglib.c ../include/ecpglib.h ../include/ecpgtype.h
-	$(CC) $(CFLAGS) -I../include $(PQ_INCLUDE) -c $< -o $@
-typename.o : typename.c ../include/ecpgtype.h
-	$(CC) $(CFLAGS) -I../include $(PQ_INCLUDE) -c $< -o $@
+ifeq (depend,$(wildcard depend))
+include depend
+endif
diff --git a/src/interfaces/libpgtcl/Makefile.in b/src/interfaces/libpgtcl/Makefile.in
index c072f136628..a70245f9880 100644
--- a/src/interfaces/libpgtcl/Makefile.in
+++ b/src/interfaces/libpgtcl/Makefile.in
@@ -5,9 +5,8 @@
 #
 # Copyright (c) 1994, Regents of the University of California
 #
-#
 # IDENTIFICATION
-#    $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/Makefile.in,v 1.32 1998/10/18 19:40:54 tgl Exp $
+#    $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/Makefile.in,v 1.33 1998/10/19 00:00:41 tgl Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -18,121 +17,25 @@ SO_MINOR_VERSION= 0
 SRCDIR= @top_srcdir@
 include $(SRCDIR)/Makefile.global
 
-INCLUDE_OPT= \
-             -I$(SRCDIR)/backend \
-             -I$(SRCDIR)/include \
-             -I$(LIBPQDIR)
-
-PORTNAME=@PORTNAME@
+CFLAGS+= -I$(SRCDIR)/backend \
+         -I$(SRCDIR)/include \
+         -I$(LIBPQDIR)
 
-CFLAGS+= $(INCLUDE_OPT)
 ifdef KRBVERS
 CFLAGS+= $(KRBFLAGS)
 endif
 
-# Shared library stuff
-
-install-shlib-dep :=
-shlib             := 
-
-LIBPQ= -L$(SRCDIR)/interfaces/libpq -lpq
-
-ifeq ($(PORTNAME), linux)
-  install-shlib-dep	:= install-shlib
-  shlib				:= lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
-  CFLAGS			+= $(CFLAGS_SL)
-  LDFLAGS_SL		= -shared
-endif
-
-ifeq ($(PORTNAME), bsd)
-  ifdef BSD_SHLIB
-    install-shlib-dep	:= install-shlib
-    shlib				:= lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
-    LDFLAGS_SL			= -x -Bshareable -Bforcearchive
-    CFLAGS				+= $(CFLAGS_SL)
-  endif
-endif
-
-ifeq ($(PORTNAME), bsdi)
-  ifdef BSD_SHLIB
-    ifeq ($(DLSUFFIX), .so)
-      install-shlib-dep	:= install-shlib
-      shlib				:= lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
-      LDFLAGS_SL		+= -shared
-      CFLAGS			+= $(CFLAGS_SL)
-    endif
-    ifeq ($(DLSUFFIX), .o)
-      install-shlib-dep	:= install-shlib
-      shlib				:= lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
-      LD				:= shlicc
-      LDFLAGS_SL		+= -O -r
-      CFLAGS			+= $(CFLAGS_SL)
-    endif
-  endif
-endif
-
-ifeq ($(PORTNAME), solaris_sparc)
-  install-shlib-dep	:= install-shlib
-  shlib				:= lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
-  LDFLAGS_SL		:= -G
-  CFLAGS			+= $(CFLAGS_SL)
-endif
-
-ifeq ($(PORTNAME), solaris_i386)
-  install-shlib-dep	:= install-shlib
-  shlib				:= lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
-  LDFLAGS_SL		:= -G
-  CFLAGS			+= $(CFLAGS_SL)
-endif
-
-ifeq ($(PORTNAME), svr4)
-  install-shlib-dep	:= install-shlib
-  shlib				:= lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
-  LDFLAGS_SL		:= -G
-  CFLAGS			+= $(CFLAGS_SL)
-endif
-
-ifeq ($(PORTNAME), unixware)
-  install-shlib-dep	:= install-shlib
-  shlib				:= lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
-  LDFLAGS_SL		:= -G -z text
-  CFLAGS			+= $(CFLAGS_SL)
-endif
-
-ifeq ($(PORTNAME), univel)
-  install-shlib-dep	:= install-shlib
-  shlib				:= lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
-  LDFLAGS_SL		:= -G -z text
-  CFLAGS			+= $(CFLAGS_SL)
-endif
-
-ifeq ($(PORTNAME), hpux)
-  install-shlib-dep	:= install-shlib
-  shlib				:= lib$(NAME)$(DLSUFFIX)
-  LDFLAGS_SL		:= -b
-  CFLAGS			+= $(CFLAGS_SL)
-endif
-
 OBJS= pgtcl.o pgtclCmds.o pgtclId.o
 
+SHLIB_LINK= -L../libpq -lpq
 
-all: lib$(NAME).a $(shlib)
-
-lib$(NAME).a: $(OBJS)
-ifdef MK_NO_LORDER
-	$(AR) $(AROPT) lib$(NAME).a $(OBJS)
-else
-	$(AR) $(AROPT) lib$(NAME).a `lorder $(OBJS) | tsort`
-endif
-	$(RANLIB) lib$(NAME).a
+# Shared library stuff, also default 'all' target
+include $(SRCDIR)/Makefile.shlib
 
-$(shlib): $(OBJS)
-	$(LD) $(LDFLAGS_SL) -o $@ $(OBJS) $(LIBPQ)
 
-.PHONY: beforeinstall-headers install-headers
-.PHONY: install install-libpgtcl install-shlib
+.PHONY: install beforeinstall-headers install-headers
 
-install: install-headers install-libpgtcl $(install-shlib-dep)
+install: install-headers install-lib $(install-shlib-dep)
 
 install-headers: beforeinstall-headers libpgtcl.h
 	$(INSTALL) $(INSTLOPTS) libpgtcl.h $(HEADERDIR)/libpgtcl.h
@@ -140,24 +43,14 @@ install-headers: beforeinstall-headers libpgtcl.h
 beforeinstall-headers:
 	@if [ ! -d $(HEADERDIR) ]; then mkdir $(HEADERDIR); fi
 
-install-libpgtcl: lib$(NAME).a
-	$(INSTALL) $(INSTL_LIB_OPTS) lib$(NAME).a $(LIBDIR)/lib$(NAME).a
-
-install-shlib: $(shlib)
-	$(INSTALL) $(INSTL_SHLIB_OPTS) $(shlib) $(LIBDIR)/$(shlib)
-	if [ "$(shlib)" != "lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)" ]; then \
-		cd $(LIBDIR); \
-		rm -f lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION); \
-		$(LN_S) $(shlib) lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION); \
-	fi
-	if [ "$(shlib)" != "lib$(NAME)$(DLSUFFIX)" ]; then \
-		cd $(LIBDIR); \
-		rm -f lib$(NAME)$(DLSUFFIX); \
-		$(LN_S) $(shlib) lib$(NAME)$(DLSUFFIX); \
-	fi
 
 .PHONY: clean
 clean: 
 	rm -f $(OBJS) $(shlib) lib$(NAME).a
 
-dep depend:
+depend dep:
+	$(CC) -MM $(CFLAGS) *.c >depend
+
+ifeq (depend,$(wildcard depend))
+include depend
+endif
diff --git a/src/interfaces/libpq++/Makefile.in b/src/interfaces/libpq++/Makefile.in
index f3a8eaead98..5a1fc34f85b 100644
--- a/src/interfaces/libpq++/Makefile.in
+++ b/src/interfaces/libpq++/Makefile.in
@@ -5,9 +5,8 @@
 #
 # Copyright (c) 1994, Regents of the University of California
 #
-#
 # IDENTIFICATION
-#    $Header: /cvsroot/pgsql/src/interfaces/libpq++/Attic/Makefile.in,v 1.9 1998/10/18 19:40:55 tgl Exp $
+#    $Header: /cvsroot/pgsql/src/interfaces/libpq++/Attic/Makefile.in,v 1.10 1998/10/19 00:00:46 tgl Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -18,148 +17,50 @@ SO_MINOR_VERSION= 0
 SRCDIR= @top_srcdir@
 include $(SRCDIR)/Makefile.global
 
-PORTNAME=@PORTNAME@
-
 CXX=@CXX@
 
 SRCHEADERDIR = $(SRCDIR)/include
 LIBPQHEADERDIR = $(SRCHEADERDIR)/libpq
 
-# We have to override -Werror, which makes warnings, fatal, because we
+# We have to override -Werror, which makes warnings fatal, because we
 # inevitably get the warning, "abstract declarator used as declaration"
 # because of our inclusion of c.h and we don't know how to stop that.
 
 ifeq ($(CXX), g++)
-CXXFLAGS= $(CFLAGS) -Wno-error
+CXXFLAGS= -Wno-error
 else
-CXXFLAGS= $(CFLAGS)
+CXXFLAGS=
 endif
 
-INCLUDE_OPT= \
-             -I$(SRCDIR)/backend \
+CXXFLAGS+=   -I$(SRCDIR)/backend \
              -I$(SRCHEADERDIR) \
              -I$(LIBPQDIR)
 
-CXXFLAGS+= $(INCLUDE_OPT)
 #CXXFLAGS+= -DDEBUG
 
 ifdef KRBVERS
 CXXFLAGS+= $(KRBFLAGS)
 endif
 
-
 OBJS = pgenv.o pgconnection.o pgtransdb.o pgcursordb.o pglobject.o
 
-# Shared library stuff
-shlib := 
-install-shlib-dep :=
-
-ifeq ($(PORTNAME), linux)
-  install-shlib-dep	:= install-shlib
-  shlib				:= lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
-  LDFLAGS_SL		:= -shared -soname lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
-  CFLAGS			+= $(CFLAGS_SL)
-endif
-
-ifeq ($(PORTNAME), bsd)
-  ifdef BSD_SHLIB
-    install-shlib-dep	:= install-shlib
-    shlib				:= lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
-    LDFLAGS_SL			:= -x -Bshareable -Bforcearchive
-    CFLAGS				+= $(CFLAGS_SL)
-  endif
-endif
-
-ifeq ($(PORTNAME), bsdi)
-  ifdef BSD_SHLIB
-    ifeq ($(DLSUFFIX), .so)
-      install-shlib-dep := install-shlib
-      shlib				:= lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
-      LDFLAGS_SL		+= -shared
-      CFLAGS			+= $(CFLAGS_SL)
-    endif
-    ifeq ($(DLSUFFIX), .o)
-      install-shlib-dep	:= install-shlib
-      shlib				:= lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
-      LD				:= shlicc
-      LDFLAGS_SL	 	+= -O -r
-      CFLAGS			+= $(CFLAGS_SL)
-    endif
-  endif
-endif
-
-ifeq ($(PORTNAME), solaris_sparc)
-  install-shlib-dep	:= install-shlib
-  shlib				:= lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
-  LDFLAGS_SL		:= -G
-  CFLAGS			+= $(CFLAGS_SL)
-endif
-
-ifeq ($(PORTNAME), solaris_i386)
-  install-shlib-dep	:= install-shlib
-  shlib				:= lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
-  LDFLAGS_SL		:= -G
-  CFLAGS			+= $(CFLAGS_SL)
-endif
-
-ifeq ($(PORTNAME), svr4)
-  install-shlib-dep	:= install-shlib
-  shlib				:= lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
-  LDFLAGS_SL		:= -G
-  CFLAGS			+= $(CFLAGS_SL)
-endif
-
-ifeq ($(PORTNAME), unixware)
-  install-shlib-dep	:= install-shlib
-  shlib				:= lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
-  LDFLAGS_SL		:= -G -z text
-  CFLAGS			+= $(CFLAGS_SL)
-  ifeq ($(CXX), CC)
-    CXXFLAGS += -Xw
-    COMPILE.cc = $(CXX) $(CXXFLAGS:ll,alloca=ll) $(CPPFLAGS) $(TARGET_ARCH) -c
-  endif
-endif
-
-ifeq ($(PORTNAME), univel)
-  install-shlib-dep	:= install-shlib
-  shlib				:= lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
-  LDFLAGS_SL		:= -G -z text
-  CFLAGS			+= $(CFLAGS_SL)
-  ifeq ($(CXX), CC)
-    CXXFLAGS += -Xw
-    COMPILE.cc = $(CXX) $(CXXFLAGS:ll,alloca=ll) $(CPPFLAGS) $(TARGET_ARCH) -c
-  endif
-endif
-
-ifeq ($(PORTNAME), hpux)
-  install-shlib-dep	:= install-shlib
-  shlib				:= lib$(NAME).sl
-  LDFLAGS_SL		:= -b
-  CFLAGS			+= $(CFLAGS_SL)
-endif
+SHLIB_LINK= -L../libpq -lpq
 
+# Shared library stuff, also default 'all' target
+include $(SRCDIR)/Makefile.shlib
 
-all: libpq++.a $(shlib)
 
-libpq++.a: $(OBJS)
-ifdef MK_NO_LORDER
-	$(AR) $(AROPT) libpq++.a $(OBJS)
-else
-	$(AR) $(AROPT) libpq++.a `lorder $(OBJS) | tsort`
-endif
-	$(RANLIB) libpq++.a
+# Pull shared-lib CFLAGS into CXXFLAGS
+CXXFLAGS+= $(CFLAGS)
 
-$(shlib): $(OBJS)
-	$(LD) $(LDFLAGS_SL) -o $@ $(OBJS)
 
 .PHONY: examples
 examples:
 	$(MAKE) -C examples all
 
-.PHONY: beforeinstall-headers install-headers 
-.PHONY: install beforeinstall-lib install-libpq++ install-shlib
+.PHONY: install beforeinstall-headers install-headers 
 
-install: install-headers install-libpq++ $(install-shlib-dep)
+install: install-headers install-lib $(install-shlib-dep)
 
 LIBPGXXDIR = libpq++
 LIBPGXXHEADERDIR = $(HEADERDIR)/$(LIBPGXXDIR)
@@ -182,32 +83,13 @@ beforeinstall-headers:
 	@if [ ! -d $(HEADERDIR) ]; then mkdir $(HEADERDIR); fi
 	@if [ ! -d $(LIBPGXXHEADERDIR) ]; then mkdir $(LIBPGXXHEADERDIR); fi
 
-beforeinstall-lib:
-	@if [ ! -d $(LIBDIR) ] ; then mkdir $(LIBDIR); fi
-
-install-libpq++: libpq++.a beforeinstall-lib
-	$(INSTALL) $(INSTL_LIB_OPTS) libpq++.a $(LIBDIR)/libpq++.a
-
-install-shlib: $(shlib)
-	$(INSTALL) $(INSTL_SHLIB_OPTS) $(shlib) $(LIBDIR)/$(shlib)
-	if [ "$(shlib)" != "lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)" ]; then \
-		cd $(LIBDIR); \
-		rm -f lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION); \
-		$(LN_S) $(shlib) lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION); \
-	fi
-	if [ "$(shlib)" != "lib$(NAME)$(DLSUFFIX)" ]; then \
-		cd $(LIBDIR); \
-		rm -f lib$(NAME)$(DLSUFFIX); \
-		$(LN_S) $(shlib) lib$(NAME)$(DLSUFFIX); \
-	fi
-
 .PHONY: clean
 clean:
 	rm -f libpq++.a $(shlib) $(OBJS)
 	$(MAKE) -C examples clean
 
 dep depend:
-	$(CXX) -MM $(CXXFLAGS) *.cc > depend
+	$(CXX) -MM $(CXXFLAGS) *.cc >depend
 
 ifeq (depend,$(wildcard depend))
 include depend
diff --git a/src/interfaces/libpq/Makefile.in b/src/interfaces/libpq/Makefile.in
index 7d9d8b57417..cff9f428349 100644
--- a/src/interfaces/libpq/Makefile.in
+++ b/src/interfaces/libpq/Makefile.in
@@ -5,9 +5,8 @@
 #
 # Copyright (c) 1994, Regents of the University of California
 #
-#
 # IDENTIFICATION
-#    $Header: /cvsroot/pgsql/src/interfaces/libpq/Attic/Makefile.in,v 1.39 1998/10/18 19:40:55 tgl Exp $
+#    $Header: /cvsroot/pgsql/src/interfaces/libpq/Attic/Makefile.in,v 1.40 1998/10/19 00:00:43 tgl Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -18,8 +17,6 @@ SO_MINOR_VERSION= 0
 SRCDIR= @top_srcdir@
 include $(SRCDIR)/Makefile.global
 
-PORTNAME= @PORTNAME@
-
 CFLAGS+= -DFRONTEND
 
 ifdef KRBVERS
@@ -37,96 +34,9 @@ ifdef MULTIBYTE
 OBJS+= common.o wchar.o conv.o
 endif
 
-# Shared library stuff
-shlib := 
-install-shlib-dep :=
-
-ifeq ($(PORTNAME), linux)
-  install-shlib-dep	:= install-shlib
-  shlib				:= lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
-  LDFLAGS_SL		:= -shared -soname lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
-  CFLAGS			+= $(CFLAGS_SL)
-endif
-
-ifeq ($(PORTNAME), bsd)
-  ifdef BSD_SHLIB
-    install-shlib-dep	:= install-shlib
-    shlib				:= lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
-    LDFLAGS_SL			:= -x -Bshareable -Bforcearchive
-    CFLAGS				+= $(CFLAGS_SL)
-  endif
-endif
-
-ifeq ($(PORTNAME), bsdi)
-  ifdef BSD_SHLIB
-    ifeq ($(DLSUFFIX), .so)
-      install-shlib-dep := install-shlib
-      shlib				:= lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
-      LDFLAGS_SL		+= -shared
-      CFLAGS			+= $(CFLAGS_SL)
-    endif
-    ifeq ($(DLSUFFIX), .o)
-      install-shlib-dep	:= install-shlib
-      shlib				:= lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
-      LD				:= shlicc
-      LDFLAGS_SL	 	+= -O -r
-      CFLAGS			+= $(CFLAGS_SL)
-    endif
-  endif
-endif
-
-ifeq ($(PORTNAME), solaris_sparc)
-  install-shlib-dep	:= install-shlib
-  shlib				:= lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
-  LDFLAGS_SL		:= -G
-  CFLAGS			+= $(CFLAGS_SL)
-endif
-
-ifeq ($(PORTNAME), solaris_i386)
-  install-shlib-dep	:= install-shlib
-  shlib				:= lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
-  LDFLAGS_SL		:= -G
-  CFLAGS			+= $(CFLAGS_SL)
-endif
-
-ifeq ($(PORTNAME), svr4)
-  install-shlib-dep	:= install-shlib
-  shlib				:= lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
-  LDFLAGS_SL		:= -G
-  CFLAGS			+= $(CFLAGS_SL)
-endif
-
-ifeq ($(PORTNAME), unixware)
-  install-shlib-dep	:= install-shlib
-  shlib				:= lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
-  LDFLAGS_SL		:= -G -z text
-  CFLAGS			+= $(CFLAGS_SL)
-endif
+# Shared library stuff, also default 'all' target
+include $(SRCDIR)/Makefile.shlib
 
-ifeq ($(PORTNAME), univel)
-  install-shlib-dep	:= install-shlib
-  shlib				:= lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
-  LDFLAGS_SL		:= -G -z text
-  CFLAGS			+= $(CFLAGS_SL)
-endif
-
-ifeq ($(PORTNAME), hpux)
-  install-shlib-dep	:= install-shlib
-  shlib				:= lib$(NAME).sl
-  LDFLAGS_SL		:= -b
-  CFLAGS			+= $(CFLAGS_SL)
-endif
-
-
-all: libpq.a $(shlib)
-
-libpq.a: $(OBJS)
-ifdef MK_NO_LORDER
-	$(AR) $(AROPT) libpq.a $(OBJS) 
-else
-	$(AR) $(AROPT) libpq.a `lorder $(OBJS) | tsort`
-endif
-	$(RANLIB) libpq.a
 
 # We need to compile this with special options for shared libs,
 # so we can't use the object in $(SRCDIR)/backend
@@ -154,14 +64,10 @@ fe-lobj.o: $(SRCDIR)/backend/fmgr.h
 $(SRCDIR)/backend/fmgr.h:
 	$(MAKE) -C $(SRCDIR)/backend fmgr.h
 
-$(shlib): $(OBJS)
-	$(LD) $(LDFLAGS_SL) -o $@ $(OBJS) 
-
 
-.PHONY: beforeinstall-headers install-headers
-.PHONY: install install-libpq install-shlib
+.PHONY: install beforeinstall-headers install-headers
 
-install: install-headers install-libpq $(install-shlib-dep)
+install: install-headers install-lib $(install-shlib-dep)
 
 # Many of the headers we install below have nothing to do with libpq,
 # so should be installed by someone else.
@@ -224,22 +130,6 @@ beforeinstall-headers:
 	@if [ ! -d $(HEADERDIR)/commands ]; \
 		then mkdir $(HEADERDIR)/commands; fi
 
-install-libpq: libpq.a
-	$(INSTALL) $(INSTL_LIB_OPTS) libpq.a $(LIBDIR)/libpq.a
-
-install-shlib: $(shlib)
-	$(INSTALL) $(INSTL_SHLIB_OPTS) $(shlib) $(LIBDIR)/$(shlib)
-	if [ "$(shlib)" != "lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)" ]; then \
-		cd $(LIBDIR); \
-		rm -f lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION); \
-		$(LN_S) $(shlib) lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION); \
-	fi
-	if [ "$(shlib)" != "lib$(NAME)$(DLSUFFIX)" ]; then \
-		cd $(LIBDIR); \
-		rm -f lib$(NAME)$(DLSUFFIX); \
-		$(LN_S) $(shlib) lib$(NAME)$(DLSUFFIX); \
-	fi
-
 
 .PHONY: clean
 clean:
diff --git a/src/interfaces/odbc/GNUmakefile.in b/src/interfaces/odbc/GNUmakefile.in
index bb97b0b15d6..39950e30571 100644
--- a/src/interfaces/odbc/GNUmakefile.in
+++ b/src/interfaces/odbc/GNUmakefile.in
@@ -7,7 +7,7 @@
 #
 #
 # IDENTIFICATION
-#    $Header: /cvsroot/pgsql/src/interfaces/odbc/Attic/GNUmakefile.in,v 1.6 1998/10/18 19:40:56 tgl Exp $
+#    $Header: /cvsroot/pgsql/src/interfaces/odbc/Attic/GNUmakefile.in,v 1.7 1998/10/19 00:00:49 tgl Exp $
 #
 #-------------------------------------------------------------------------
 @SET_MAKE@
@@ -18,33 +18,13 @@ ODBCSRCDIR= @srcdir@
 include $(SRCDIR)/Makefile.global
 
 include Version.mk
-PORTNAME= @PORTNAME@
 
 FIND= @find@
 # assuming gnu tar and split here
 TAR= @tar@
 SPLIT= @split@
 
-# Shared library stuff
-shlib := 
-install-shlib-dep :=
-
-ifeq ($(PORTNAME), linux)
-  install-shlib-dep := install-shlib
-  shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
-  LDFLAGS_SL = -shared -soname lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
-  LDFLAGS_SL += -Bsymbolic $(LDFLAGS) -lc -lm
-  CFLAGS += $(CFLAGS_SL)
-endif
-
-ifeq ($(PORTNAME), bsd)
-  ifdef BSD_SHLIB
-    install-shlib-dep := install-shlib
-    shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
-    LDFLAGS_SL = -x -Bshareable -Bforcearchive $(LDFLAGS)
-    CFLAGS += $(CFLAGS_SL)
-  endif
-endif
+CFLAGS += -I. @DEFS@
 
 SOURCES = *.c *.h *.in Config.mk \
 	TODO.txt Version.mk config.guess config.sub configure \
@@ -52,28 +32,21 @@ SOURCES = *.c *.h *.in Config.mk \
 	psqlodbc.def \
 	psqlodbc.rc readme.txt
 
-OBJECTS = info.o bind.o columninfo.o connection.o convert.o drvconn.o \
+OBJS = info.o bind.o columninfo.o connection.o convert.o drvconn.o \
         environ.o execute.o lobj.o misc.o options.o \
         pgtypes.o psqlodbc.o qresult.o results.o socket.o parse.o statement.o \
         gpps.o tuple.o tuplelist.o dlg_specific.o $(OBJX)
 
-CFLAGS += -I. @DEFS@
-
-all: libpsqlodbc.a $(shlib)
+SHLIB_LINK= $(LIBS)
 
-libpsqlodbc.a: $(OBJECTS)
-	$(AR) $(AROPT) libpsqlodbc.a $(OBJECTS)
-	$(RANLIB) libpsqlodbc.a
+# Shared library stuff, also default 'all' target
+include $(SRCDIR)/Makefile.shlib
 
-$(shlib): $(OBJECTS)
-	$(LD) $(LDFLAGS_SL) $(OBJECTS) \
-	-o $(shlib) $(LIBS)
 
-.PHONY: beforeinstall-headers install-headers
-.PHONY: install install-libpsqlodbc install-ini install-shlib
+.PHONY: install install-ini beforeinstall-headers install-headers
 
 install: $(HEADERDIR) $(LIBDIR) $(ODBCINST) install-headers \
-	install-libpsqlodbc install-ini $(install-shlib-dep)
+	install-ini install-lib $(install-shlib-dep)
 
 $(HEADERDIR) $(LIBDIR) $(ODBCINST):
 	mkdir -p $@
@@ -86,32 +59,13 @@ install-headers: beforeinstall-headers isql.h isqlext.h iodbc.h
 beforeinstall-headers:
 	@if [ ! -d $(HEADERDIR)/iodbc ]; then mkdir -p $(HEADERDIR)/iodbc; fi
 
-install-libpsqlodbc: libpsqlodbc.a
-	$(INSTALL) $(INSTL_LIB_OPTS) libpsqlodbc.a $(LIBDIR)/lib$(NAME).a
-
-install-shlib: $(shlib)
-	$(INSTALL) $(INSTL_SHLIB_OPTS) $(shlib) $(LIBDIR)/$(shlib)
-	if [ "$(shlib)" != "lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)" ]; then \
-		cd $(LIBDIR); \
-		rm -f lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION); \
-		$(LN_S) $(shlib) lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION); \
-	fi
-	if [ "$(shlib)" != "lib$(NAME)$(DLSUFFIX)" ]; then \
-		cd $(LIBDIR); \
-		rm -f lib$(NAME)$(DLSUFFIX); \
-		$(LN_S) $(shlib) lib$(NAME)$(DLSUFFIX); \
-	fi
-
 install-ini: odbcinst.ini
-	$(INSTALL) $(INSTL_LIB_OPTS) odbcinst.ini $(ODBCINST)
-
-depend dep:
-	$(CC) -MM *.c >depend
+	$(INSTALL) $(INSTL_LIB_OPTS) odbcinst.ini $(ODBCINST)/odbcinst.ini
 
 .PHONY: clean
 
 clean:
-	-rm -f lib$(NAME).a $(shlib) $(OBJECTS) lib$(NAME)$(DLSUFFIX)
+	-rm -f lib$(NAME).a $(shlib) $(OBJS)
 
 .PHONY: distclean
 
@@ -141,3 +95,10 @@ integrated:
 	-rm -f psqlodbc-$(SO_MAJOR_VERSION)$(SO_MINOR_VERSION)-int.tar.gz
 	$(TAR) -cf psqlodbc-$(SO_MAJOR_VERSION)$(SO_MINOR_VERSION)-int.tar $(SOURCES)
 	gzip psqlodbc-$(SO_MAJOR_VERSION)$(SO_MINOR_VERSION)-int.tar
+
+depend dep:
+	$(CC) -MM $(CFLAGS) *.c >depend
+
+ifeq (depend,$(wildcard depend))
+include depend
+endif
diff --git a/src/interfaces/odbc/Makefile.global.in b/src/interfaces/odbc/Makefile.global.in
index c1374167ef7..5684757be5a 100644
--- a/src/interfaces/odbc/Makefile.global.in
+++ b/src/interfaces/odbc/Makefile.global.in
@@ -7,7 +7,7 @@
 #
 #
 # IDENTIFICATION
-#    $Header: /cvsroot/pgsql/src/interfaces/odbc/Attic/Makefile.global.in,v 1.3 1998/10/18 19:40:56 tgl Exp $
+#    $Header: /cvsroot/pgsql/src/interfaces/odbc/Attic/Makefile.global.in,v 1.4 1998/10/19 00:00:49 tgl Exp $
 #
 # NOTES
 #    This is derived from the main Postgres makefile.
@@ -131,6 +131,13 @@ LDFLAGS= @LDFLAGS@ @LIBS@
 DLSUFFIX= @DLSUFFIX@
 LN_S = @LN_S@
 
+##############################################################################
+#
+# Additional platform-specific settings
+#
+
+PORTNAME= @PORTNAME@
+
 ifneq ($(wildcard $(SRCDIR)/Makefile.port), )
   include $(SRCDIR)/Makefile.port
 endif
diff --git a/src/pl/plpgsql/src/Makefile.in b/src/pl/plpgsql/src/Makefile.in
index eeb8271b26f..7fd08f57b5a 100644
--- a/src/pl/plpgsql/src/Makefile.in
+++ b/src/pl/plpgsql/src/Makefile.in
@@ -4,120 +4,40 @@
 #    Makefile for the plpgsql shared object
 #
 # IDENTIFICATION
-#    $Header: /cvsroot/pgsql/src/pl/plpgsql/src/Attic/Makefile.in,v 1.9 1998/10/18 19:40:58 tgl Exp $
+#    $Header: /cvsroot/pgsql/src/pl/plpgsql/src/Attic/Makefile.in,v 1.10 1998/10/19 00:00:51 tgl Exp $
 #
 #-------------------------------------------------------------------------
 
-#
-# Tell make where the postgresql sources live
-#
-SRCDIR= ../../..
+NAME= plpgsql
+SO_MAJOR_VERSION= 1
+SO_MINOR_VERSION= 0
 
-#
-# Include the global and port specific Makefiles
-#
+SRCDIR= @top_srcdir@
 include $(SRCDIR)/Makefile.global
 
-PORTNAME=@PORTNAME@
-
 CFLAGS+= -I$(LIBPQDIR) -I$(SRCDIR)/include
-LFLAGS+= -i -l
 
 # For fmgr.h
 CFLAGS+= -I$(SRCDIR)/backend
 
-LDADD+= -L$(LIBPQDIR) -lpq
-
-ifeq ($(PORTNAME), linux)
-  CFLAGS		+= $(CFLAGS_SL)
-  LDFLAGS_SL		= -shared
-endif
-
-ifeq ($(PORTNAME), bsd)
-  ifdef BSD_SHLIB
-    LDFLAGS_SL		= -x -Bshareable -Bforcearchive
-    CFLAGS		+= $(CFLAGS_SL)
-  endif
-endif
-
-ifeq ($(PORTNAME), bsdi)
-  ifdef BSD_SHLIB
-    ifeq ($(DLSUFFIX), .so)
-      LDFLAGS_SL	+= -shared
-      CFLAGS		+= $(CFLAGS_SL)
-    endif
-    ifeq ($(DLSUFFIX), .o)
-      LD		:= shlicc
-      LDFLAGS_SL	+= -O -r
-      CFLAGS		+= $(CFLAGS_SL)
-    endif
-  endif
-endif
-
-ifeq ($(PORTNAME), solaris_sparc)
-  LDFLAGS_SL		:= -G
-  CFLAGS		+= $(CFLAGS_SL)
-endif
-
-ifeq ($(PORTNAME), solaris_i386)
-  LDFLAGS_SL		:= -G
-  CFLAGS		+= $(CFLAGS_SL)
-endif
-
-ifeq ($(PORTNAME), svr4)
-  LDFLAGS_SL		:= -G
-  CFLAGS		+= $(CFLAGS_SL)
-endif
-
-ifeq ($(PORTNAME), unixware)
-  LDFLAGS_SL		:= -G -z text
-  CFLAGS		+= $(CFLAGS_SL)
-endif
-
-ifeq ($(PORTNAME), univel)
-  LDFLAGS_SL		:= -G -z text
-  CFLAGS		+= $(CFLAGS_SL)
-endif
-
-ifeq ($(PORTNAME), hpux)
-  LDFLAGS_SL		:= -b
-  CFLAGS		+= $(CFLAGS_SL)
-endif
-
-#
-# DLOBJ is the dynamically-loaded object file.
-#
-DLOBJ= plpgsql$(DLSUFFIX)
-
-OBJS=	plpgsql.o
-
-PLOBJS=	pl_parse.o pl_handler.o pl_comp.o pl_exec.o pl_funcs.o
-
-ALL=	$(DLOBJ)
-
-#
-# Build the shared object
-#
-all: $(ALL)
+LFLAGS+= -i -l
 
-$(OBJS):	$(PLOBJS)
-	$(LD) -r -o $(OBJS) $(PLOBJS)
+OBJS=	pl_parse.o pl_handler.o pl_comp.o pl_exec.o pl_funcs.o
 
-$(DLOBJ):	$(OBJS)
+SHLIB_LINK= -L$(LIBPQDIR) -lpq
 
-#
-# Clean 
-#
-clean:
-	rm -f $(ALL)
-	rm -f *.o y.tab.h pl.tab.h pl_gram.c gram.c pl_scan.c scan.c
+# Shared library stuff, also default 'all' target
+include $(SRCDIR)/Makefile.shlib
 
-install: all
-	$(INSTALL) $(INSTL_SHLIB_OPTS) $(DLOBJ) $(DESTDIR)$(LIBDIR)/$(DLOBJ)
 
-$(DLOBJ):	$(OBJS)
-	$(LD) $(LDFLAGS_SL) -o $@ $(OBJS)
+# In order to use Makefile.shlib, we allow it to build a static library
+# libplpgsql.a, which we just ignore, as well as a shared library that
+# it will insist on naming $(shlib).  We don't want to call it that when
+# installed, however, so we ignore the install-shlib rule and do this
+# instead:
 
+install: $(shlib)
+	$(INSTALL) $(INSTL_SHLIB_OPTS) $(shlib) $(LIBDIR)/plpgsql$(DLSUFFIX)
 
 
 pl_handler.o:	pl_handler.c plpgsql.h pl.tab.h
@@ -143,3 +63,10 @@ gram.c:		gram.y
 scan.c:		scan.l
 
 pl.tab.h:	pl_gram.c
+
+
+.PHONY: clean
+
+clean:
+	rm -f lib$(NAME).a $(shlib)
+	rm -f *.o y.tab.h pl.tab.h pl_gram.c gram.c pl_scan.c scan.c
-- 
GitLab