*** src/bin/pgtclsh/Makefile.orig	Sat Oct 10 13:09:56 1998
--- src/bin/pgtclsh/Makefile	Sat Oct 10 19:47:25 1998
***************
*** 14,21 ****
  SRCDIR= ../..
  include ../../Makefile.global
  
! CFLAGS+=  $(X_CFLAGS) -I$(SRCDIR)/interfaces/libpgtcl
  
  ifdef KRBVERS
  LDFLAGS+= $(KRBLIBS)
  CFLAGS+= $(KRBFLAGS)
--- 14,26 ----
  SRCDIR= ../..
  include ../../Makefile.global
  
! #
! # Include definitions from the tclConfig.sh file
! #
! include Makefile.tcltkdefs
  
+ CFLAGS+=  -I$(SRCDIR)/interfaces/libpgtcl 
+ 
  ifdef KRBVERS
  LDFLAGS+= $(KRBLIBS)
  CFLAGS+= $(KRBFLAGS)
***************
*** 27,40 ****
  
  all: pgtclsh pgtksh
  
  pgtclsh: pgtclAppInit.o
! 	$(CC) $(CFLAGS) -o $@ pgtclAppInit.o \
! 	  $(LIBPGTCL) $(LIBPQ) $(TCL_LIB) -lm $(LDFLAGS)
  
  pgtksh: pgtkAppInit.o
! 	$(CC) $(CFLAGS) -o $@ pgtkAppInit.o \
! 	  $(LIBPGTCL) $(LIBPQ) $(X_LIBS) $(TK_LIB) $(TCL_LIB) \
! 	  $(X11_LIBS) -lm $(LDFLAGS)
  
  install: pgtclsh pgtksh
  	$(INSTALL) $(INSTL_EXE_OPTS) pgtclsh $(BINDIR)/pgtclsh
--- 32,48 ----
  
  all: pgtclsh pgtksh
  
+ Makefile.tcltkdefs:
+ 	/bin/sh mkMakefile.tcltkdefs.sh
+ 
  pgtclsh: pgtclAppInit.o
! 	$(CC) $(CFLAGS) $(TCL_DEFS) -o $@ pgtclAppInit.o \
! 	  $(LIBPGTCL) $(LIBPQ) $(TCL_LIB_SPEC) $(TCL_LIBS) $(LDFLAGS)
  
  pgtksh: pgtkAppInit.o
! 	$(CC) $(CFLAGS) $(TK_DEFS) -o $@ pgtkAppInit.o \
! 	  $(LIBPGTCL) $(LIBPQ) $(TK_LIB_SPEC) $(TK_LIBS) \
! 	  $(TCL_LIB_SPEC) $(TCL_LIB) $(LDFLAGS)
  
  install: pgtclsh pgtksh
  	$(INSTALL) $(INSTL_EXE_OPTS) pgtclsh $(BINDIR)/pgtclsh
*** src/bin/pgtclsh/mkMakefile.tcltkdefs.sh.in.orig	Sat Oct 10 01:17:02 1998
--- src/bin/pgtclsh/mkMakefile.tcltkdefs.sh.in	Sat Oct 10 19:23:21 1998
***************
*** 0 ****
--- 1,29 ----
+ 
+ if [ ! -f @TCL_CONFIG_SH@ ]; then
+     echo "@TCL_CONFIG_SH@ not found"
+     echo "I need this file! Please make a symbolic link to this file"
+     echo "and start make again."
+     exit 1
+ fi
+ 
+ if [ ! -f @TK_CONFIG_SH@ ]; then
+     echo "@TK_CONFIG_SH@ not found"
+     echo "I need this file! Please make a symbolic link to this file"
+     echo "and start make again."
+     exit 1
+ fi
+ 
+ . @TCL_CONFIG_SH@
+ . @TK_CONFIG_SH@
+ 
+ set									| 
+     egrep '^TCL_|^TK_'				|
+     sed -e 's/=/="/' -e 's/$/"/'	|
+     while read v
+     do
+ 		eval "$v"
+ 		v1=`echo $v | sed -e 's/=.*//'`
+ 		eval "echo $v1 = \"\$$v1\""
+     done >Makefile.tcltkdefs
+ 
+ exit 0
*** src/interfaces/libpgtcl/Makefile.orig	Sat Oct 10 19:12:50 1998
--- src/interfaces/libpgtcl/Makefile	Sat Oct 10 19:13:57 1998
***************
*** 133,138 ****
--- 133,139 ----
  install-shlib: $(shlib)
  	$(INSTALL) $(INSTL_SHLIB_OPTS) $(shlib) \
  		$(LIBDIR)/$(shlib)
+ 	rm -f $(LIBDIR)/libpgtcl.so
  	$(LN_S) -f $(shlib) $(LIBDIR)/libpgtcl.so
  
  .PHONY: clean
*** src/interfaces/libpgtcl/Makefile.in.orig	Sat Oct 10 19:14:02 1998
--- src/interfaces/libpgtcl/Makefile.in	Sat Oct 10 19:14:33 1998
***************
*** 132,137 ****
--- 132,138 ----
  install-shlib: $(shlib)
  	$(INSTALL) $(INSTL_SHLIB_OPTS) $(shlib) \
  		$(LIBDIR)/$(shlib)
+ 	rm -f $(LIBDIR)/libpgtcl.so
  	$(LN_S) -f $(shlib) $(LIBDIR)/libpgtcl.so
  
  .PHONY: clean
*** src/pl/tcl/mkMakefile.tcldefs.sh.in.orig	Sat Oct 10 18:32:44 1998
--- src/pl/tcl/mkMakefile.tcldefs.sh.in	Sat Oct 10 19:31:38 1998
***************
*** 1,7 ****
  
! if [ -f @TCL_CONFIG_SH@ ]; then
!     . @TCL_CONFIG_SH@
! else
      echo "@TCL_CONFIG_SH@ not found"
      echo "I need this file! Please make a symbolic link to this file"
      echo "and start make again."
--- 1,5 ----
  
! if [ ! -f @TCL_CONFIG_SH@ ]; then
      echo "@TCL_CONFIG_SH@ not found"
      echo "I need this file! Please make a symbolic link to this file"
      echo "and start make again."
***************
*** 8,15 ****
      exit 1
  fi
  
! for v in `set | grep '^TCL' | sed -e 's/=.*//'` ; do
!     echo $v = `eval "echo \\$$v"`
! done >Makefile.tcldefs
  
  exit 0
--- 6,21 ----
      exit 1
  fi
  
! . @TCL_CONFIG_SH@
! 
! set												| 
!     egrep '^TCL_|^TK_'							|
!     sed -e 's/=[ 	]*/="/' -e 's/[ 	]*$/"/'	|
!     while read v
!     do
! 		eval "$v"
! 		v1=`echo $v | sed -e 's/=.*//'`
! 		eval "echo $v1 = \"\$$v1\""
!     done >Makefile.tcldefs
  
  exit 0
*** src/configure.orig	Sat Oct 10 00:50:53 1998
--- src/configure	Sat Oct 10 19:21:08 1998
***************
*** 6118,6124 ****
  if test "$USE_TCL"; then
  	echo $ac_n "checking for tclConfig.sh""... $ac_c" 1>&6
  echo "configure:6121: checking for tclConfig.sh" >&5
! 	library_dirs="/usr/lib $LIBRARY_DIRS"
  	TCL_CONFIG_SH=
  	for dir in $library_dirs; do
  		for tcl_dir in $tcl_dirs; do
--- 6118,6124 ----
  if test "$USE_TCL"; then
  	echo $ac_n "checking for tclConfig.sh""... $ac_c" 1>&6
  echo "configure:6121: checking for tclConfig.sh" >&5
! 	library_dirs="$LIBRARY_DIRS /usr/lib"
  	TCL_CONFIG_SH=
  	for dir in $library_dirs; do
  		for tcl_dir in $tcl_dirs; do
***************
*** 6268,6273 ****
--- 6268,6303 ----
  	LDFLAGS="$ice_save_LDFLAGS"
  fi
  
+ if test "$USE_TCL"; then
+ 	echo $ac_n "checking for tkConfig.sh""... $ac_c" 1>&6
+ echo "configure:6121: checking for tkConfig.sh" >&5
+ 	library_dirs="$LIBRARY_DIRS /usr/lib"
+ 	TK_CONFIG_SH=
+ 	for dir in $library_dirs; do
+ 		for tk_dir in $tk_dirs; do
+ 			if test -z "$TK_CONFIG_SH"; then
+ 				if test -d "$dir/$tk_dir" -a -r "$dir/$tk_dir/tkConfig.sh"; then
+ 					TK_CONFIG_SH=$dir/$tk_dir/tkConfig.sh
+ 				fi
+ 			fi
+ 		done
+ 		if test -z "$TK_CONFIG_SH"; then
+ 			if test -d "$dir" -a -r "$dir/tkConfig.sh"; then
+ 				TK_CONFIG_SH=$dir/tkConfig.sh
+ 			fi
+ 		fi
+ 	done
+ 	if test -z "$TK_CONFIG_SH"; then
+ 		echo "$ac_t""no" 1>&6
+ 		echo "configure: warning: tcl support disabled; Tk configuration script missing" 1>&2
+ 		USE_TCL=
+ 	else
+ 		echo "$ac_t""$TK_CONFIG_SH" 1>&6
+ 		
+ 	fi
+ fi
+ 
+ 
  #if test "X$USE_ODBC" = "Xtrue"
  #then
  #	AC_CONFIG_SUBDIRS(interfaces/odbc)
***************
*** 6424,6429 ****
--- 6454,6460 ----
  	bin/pg_dump/Makefile
  	bin/pg_version/Makefile
  	bin/psql/Makefile
+ 	bin/pgtclsh/mkMakefile.tcltkdefs.sh
  	include/version.h
  	interfaces/libpq/Makefile
  	interfaces/ecpg/lib/Makefile
***************
*** 6532,6537 ****
--- 6563,6569 ----
  s%@TCL_LIB@%$TCL_LIB%g
  s%@TCL_CONFIG_SH@%$TCL_CONFIG_SH%g
  s%@TK_LIB@%$TK_LIB%g
+ s%@TK_CONFIG_SH@%$TK_CONFIG_SH%g
  
  CEOF
  EOF
***************
*** 6580,6585 ****
--- 6612,6618 ----
  	bin/pg_dump/Makefile
  	bin/pg_version/Makefile
  	bin/psql/Makefile
+ 	bin/pgtclsh/mkMakefile.tcltkdefs.sh
  	include/version.h
  	interfaces/libpq/Makefile
  	interfaces/ecpg/lib/Makefile
*** src/configure.in.orig	Sat Oct 10 00:51:18 1998
--- src/configure.in	Sat Oct 10 19:20:38 1998
***************
*** 801,813 ****
  	else
  		TCL_LIB=-l$TCL_LIB
  	fi
- 	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
--- 801,812 ----
  	else
  		TCL_LIB=-l$TCL_LIB
  	fi
  fi
  
  dnl Check for Tcl configuration script tclConfig.sh
  if test "$USE_TCL"; then
  	AC_MSG_CHECKING(for tclConfig.sh)
! 	library_dirs="$LIBRARY_DIRS /usr/lib"
  	TCL_CONFIG_SH=
  	for dir in $library_dirs; do
  		for tcl_dir in $tcl_dirs; do
***************
*** 886,893 ****
  		TK_LIB=-l$TK_LIB
  	fi
  
- 	AC_SUBST(TK_LIB)
- 
  	LIBS="$ice_save_LIBS"
  	CFLAGS="$ice_save_CFLAGS"
  	CPPFLAGS="$ice_save_CPPFLAGS"
--- 885,890 ----
***************
*** 894,899 ****
--- 891,925 ----
  	LDFLAGS="$ice_save_LDFLAGS"
  fi
  
+ dnl Check for Tk configuration script tkConfig.sh
+ if test "$USE_TCL"; then
+ 	AC_MSG_CHECKING(for tkConfig.sh)
+ 	library_dirs="$LIBRARY_DIRS /usr/lib"
+ 	TK_CONFIG_SH=
+ 	for dir in $library_dirs; do
+ 		for tk_dir in $tk_dirs; do
+ 			if test -z "$TK_CONFIG_SH"; then
+ 				if test -d "$dir/$tk_dir" -a -r "$dir/$tk_dir/tkConfig.sh"; then
+ 					TK_CONFIG_SH=$dir/$tk_dir/tkConfig.sh
+ 				fi
+ 			fi
+ 		done
+ 		if test -z "$TK_CONFIG_SH"; then
+ 			if test -d "$dir" -a -r "$dir/tkConfig.sh"; then
+ 				TK_CONFIG_SH=$dir/tkConfig.sh
+ 			fi
+ 		fi
+ 	done
+ 	if test -z "$TK_CONFIG_SH"; then
+ 		AC_MSG_RESULT(no)
+ 		AC_MSG_WARN(tcl support disabled; Tk configuration script missing)
+ 		USE_TCL=
+ 	else
+ 		AC_MSG_RESULT($TK_CONFIG_SH)
+ 		AC_SUBST(TK_CONFIG_SH)
+ 	fi
+ fi
+ 
  dnl cause configure to recurse into subdirectories with their own configure
  dnl Darn, setting AC_CONFIG_SUBDIRS sets a list $subdirs$ in the configure output
  dnl  file, but then configure doesn't bother using that list. Probably a bug in
***************
*** 925,930 ****
--- 951,957 ----
  	bin/pg_dump/Makefile
  	bin/pg_version/Makefile
  	bin/psql/Makefile
+ 	bin/pgtclsh/mkMakefile.tcltkdefs.sh
  	include/version.h
  	interfaces/libpq/Makefile
  	interfaces/ecpg/lib/Makefile
