diff --git a/src/configure.in b/src/configure.in
index bf72426de32af18bcd95549ea2885f12e9e162b4..6c982efa4986001c2584a881ca4fb836750fbe20 100644
--- a/src/configure.in
+++ b/src/configure.in
@@ -799,6 +799,30 @@ if test "$USE_TCL" = "true"; then
 	AC_SUBST(TCL_LIB)
 fi
 
+dnl Check for Tcl configuration script tclConfig.sh
+if test "$USE_TCL"; then
+	AC_MSG_CHECKING(for tclConfig.sh)
+	library_dirs="/usr/lib $LIBRARY_DIRS"
+	TCL_CONFIG_SH=
+	for dir in $library_dirs; do
+		for tcl_dir in $tcl_dirs; do
+			if test -z "$TCL_CONFIG_SH"; then
+				if test -d "$dir/$tcl_dir" -a -r "$dir/$tcl_dir/tclConfig.sh"; then
+					TCL_CONFIG_SH=$dir/$tcl_dir/tclConfig.sh
+				fi
+			fi
+		done
+	done
+	if test -z "$TCL_CONFIG_SH"; then
+		AC_MSG_RESULT(no)
+		AC_MSG_WARN(tcl support disabled; Tcl configuration script missing)
+		USE_TCL=
+	else
+		AC_MSG_RESULT($TCL_CONFIG_SH)
+		AC_SUBST(TCL_CONFIG_SH)
+	fi
+fi
+
 dnl Check for location of Tk support (only if Tcl used)
 dnl Disable Tcl support if Tk not found
 
@@ -883,4 +907,21 @@ fi
  
 AC_CONFIG_HEADER(interfaces/odbc/config.h)
 
-AC_OUTPUT(GNUmakefile Makefile.global backend/port/Makefile bin/pg_version/Makefile bin/psql/Makefile bin/pg_dump/Makefile backend/utils/Gen_fmgrtab.sh interfaces/libpq/Makefile interfaces/libpq++/Makefile interfaces/libpgtcl/Makefile interfaces/ecpg/lib/Makefile include/version.h interfaces/odbc/Makefile.global interfaces/odbc/GNUmakefile)
+AC_OUTPUT(
+  GNUmakefile
+  Makefile.global
+  backend/port/Makefile
+  backend/utils/Gen_fmgrtab.sh
+  bin/pg_dump/Makefile
+  bin/pg_version/Makefile
+  bin/psql/Makefile
+  include/version.h
+  interfaces/ecpg/lib/Makefile
+  interfaces/libpgtcl/Makefile
+  interfaces/libpq++/Makefile
+  interfaces/libpq/Makefile
+  interfaces/odbc/GNUmakefile
+  interfaces/odbc/Makefile.global
+  pl/plpgsql/src/Makefile
+  pl/tcl/mkMakefile.tcldefs.sh
+)
diff --git a/src/pl/plpgsql/src/Makefile b/src/pl/plpgsql/src/Makefile.in
similarity index 59%
rename from src/pl/plpgsql/src/Makefile
rename to src/pl/plpgsql/src/Makefile.in
index 19adfa126ff4c11d6efc5824965b9cf5c2e4741e..95cdc6d13fc1ea31a346f013d1275cf0b37e63bc 100644
--- a/src/pl/plpgsql/src/Makefile
+++ b/src/pl/plpgsql/src/Makefile.in
@@ -4,7 +4,7 @@
 #    Makefile for the plpgsql shared object
 #
 # IDENTIFICATION
-#    $Header: /cvsroot/pgsql/src/pl/plpgsql/src/Makefile,v 1.1 1998/09/25 15:50:02 momjian Exp $
+#    $Header: /cvsroot/pgsql/src/pl/plpgsql/src/Attic/Makefile.in,v 1.1 1998/10/08 23:45:17 momjian Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -17,7 +17,8 @@ SRCDIR= ../../..
 # Include the global and port specific Makefiles
 #
 include $(SRCDIR)/Makefile.global
-include $(SRCDIR)/Makefile.port
+
+PORTNAME=@PORTNAME@
 
 CFLAGS+= -I$(LIBPQDIR) -I$(SRCDIR)/include
 LFLAGS+= -i -l
@@ -27,6 +28,53 @@ 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 ($(LDSUFFIX), .so)
+      LD		:= shlicc
+      LDFLAGS_SL	+= -O -shared
+      CFLAGS		+= $(CFLAGS_SL)
+    endif
+    ifeq ($(LDSUFFIX), .o)
+      LD		:= shlicc
+      LDFLAGS_SL	+= -O -r
+      CFLAGS		+= $(CFLAGS_SL)
+    endif
+  endif
+endif
+
+ifeq ($(PORTNAME), solaris)
+  LDFLAGS_SL		:= -G -z text
+  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.
 #
@@ -54,9 +102,8 @@ install: all
 	$(INSTALL) $(INSTL_LIB_OPTS) $(DLOBJ) $(DESTDIR)$(LIBDIR)/$(DLOBJ)
 
 $(DLOBJ):	$(OBJS)
-	$(CC) -shared -o $@ $(OBJS)
+	$(LD) $(LDFLAGS_SL) -o $@ $(OBJS)
 
-#	$(LD) $(LDFLAGS_SL) -o $@ $(OBJS)
 
 
 pl_handler.o:	pl_handler.c plpgsql.h pl.tab.h
diff --git a/src/pl/tcl/Makefile b/src/pl/tcl/Makefile
index c1768e82abdefe4beea0c3e2cb2d82b7c0316f1a..781ccdd39de04063179d8d228864fe192ff40c2a 100644
--- a/src/pl/tcl/Makefile
+++ b/src/pl/tcl/Makefile
@@ -4,7 +4,7 @@
 #    Makefile for the pltcl shared object
 #
 # IDENTIFICATION
-#    $Header: /cvsroot/pgsql/src/pl/tcl/Makefile,v 1.5 1998/04/06 16:53:15 momjian Exp $
+#    $Header: /cvsroot/pgsql/src/pl/tcl/Makefile,v 1.6 1998/10/08 23:45:18 momjian Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -77,7 +77,7 @@ endif
 all: $(INFILES)
 
 Makefile.tcldefs:
-	./mkMakefile.tcldefs
+	/bin/sh mkMakefile.tcldefs.sh
 
 #
 # Clean 
diff --git a/src/pl/tcl/mkMakefile.tcldefs b/src/pl/tcl/mkMakefile.tcldefs
deleted file mode 100755
index 9881d6bf99eeec38049fb79ab37d9e220bb6b4fe..0000000000000000000000000000000000000000
--- a/src/pl/tcl/mkMakefile.tcldefs
+++ /dev/null
@@ -1,25 +0,0 @@
-#!/bin/sh
-if [ -f ./tclConfig.sh ]; then
-    . ./tclConfig.sh
-else
-    if [ -f /usr/lib/tclConfig.sh ]; then
-	echo "using tclConfig.sh from /usr/lib"
-	. /usr/lib/tclConfig.sh
-    elif [ -f /usr/contrib/lib/tclConfig.sh ]; then
-	echo "using tclConfig.sh from /usr/contrib/lib"
-	. /usr/contrib/lib/tclConfig.sh
-    else
-	if [ -f /usr/local/lib/tclConfig.sh ]; then
-	    echo "using tclConfig.sh from /usr/local/lib"
-	    . /usr/local/lib/tclConfig.sh
-	else
-	    echo "tclConfig.sh not found in /usr/lib, /usr/contrib/lib, or /usr/local/lib"
-	    echo "I need this file! Please make a symbolic link to this file"
-	    echo "and start make again."
-	    exit 1
-        fi
-    fi
-fi
-
-set | grep '^TCL' >Makefile.tcldefs
-exit 0