In getting 6.3 working on a NetBSD/i386 box I have made up a few
patches that correct some areas of the
code/documentation/configuration.  They follow, each preceded by a
description.  I hope they are useful; they allowed me to do a complete
compilation using the --with-tcl configuration option, something I
couldn't originally.

Cheers,
Brook

===========================================================================
===========================================================================

NOTE:  All patches originate at root_of_postgresql_tarball/src.

===========================================================================
===========================================================================
Documentation on at least these configure options is missing from INSTALL.

--- ../INSTALL.orig	Mon Feb  2 01:00:13 1998
+++ ../INSTALL	Wed Feb 18 16:42:54 1998
@@ -267,6 +267,15 @@
                           listens for incoming connections on.  The
                           default for this is port 5432.
 
+       --with-defaults    Use default responses to several queries during
+                          configuration.
+
+       --with-tcl         Enables programs requiring Tcl/Tk and X11,
+                          including pgtclsh and libpgtcl.
+
+       --with-perl        Enables the perl interface.  Note that this
+                          requires an installed version of postgreSQL.
+
      As an example, here is the configure script I use on a Sparc
      Solaris 2.5 system with /opt/postgres being the install base.


===========================================================================
===========================================================================
I found that the configuration scripts were not looking for X11/tcl/tk
support and the default built into Makefile.global.in was wrong for my
system.  As a result using the --with-tcl bombed when it came to
pgtclsh and libpgtcl.  The following three patches change the
configuration system to search for X11/tcl/tk in various spots.  I
hope all the relevant possibilities are included; it's easy to add new
spots.  They also change the pgtclsh/Makefile to use the right
variables set in Makefile.global.

Note that a new configure script will need to be made with autoconf if
this patch is installed.

--- configure.in.orig	Tue Feb 17 01:00:36 1998
+++ configure.in	Wed Feb 18 18:18:09 1998
@@ -229,6 +229,7 @@
 	USE_TCL=
 fi
 export USE_TCL
+USE_X=$USE_TCL
 
 dnl We exclude perl support unless we override it with --with-perl
 if test "X$with_perl" = "Xyes"
@@ -514,5 +515,131 @@
 AC_MSG_CHECKING(setting DEF_PGPORT)
 AC_DEFINE_UNQUOTED(DEF_PGPORT, "${DEF_PGPORT}")
 AC_MSG_RESULT($DEF_PGPORT)
+
+dnl Check for X libraries
+
+if test "$USE_X" = true; then
+
+ice_save_LIBS="$LIBS"
+ice_save_CFLAGS="$CFLAGS"
+ice_save_CPPFLAGS="$CPPFLAGS"
+ice_save_LDFLAGS="$LDFLAGS"
+
+AC_PATH_XTRA
+
+LIBS="$LIBS $X_EXTRA_LIBS"
+CFLAGS="$CFLAGS $X_CFLAGS"
+CPPFLAGS="$CPPFLAGS $X_CFLAGS"
+LDFLAGS="$LDFLAGS $X_LIBS"
+
+dnl Check for X library
+
+X11_LIBS=""
+AC_CHECK_LIB(X11, XOpenDisplay, X11_LIBS="-lX11",,${X_PRE_LIBS})
+if test "$X11_LIBS" = ""; then
+dnl Not having X may be fatal.  Let the user fix this.
+AC_MSG_WARN([The X11 library '-lX11' could not be found.
+                    Please use the configure options '--x-includes=DIR'
+                    and '--x-libraries=DIR' to specify the X location.
+                    See the file 'config.log' for further diagnostics.])
+fi
+AC_SUBST(X_LIBS)
+AC_SUBST(X11_LIBS)
+AC_SUBST(X_PRE_LIBS)
+
+LIBS="$ice_save_LIBS"
+CFLAGS="$ice_save_CFLAGS"
+CPPFLAGS="$ice_save_CPPFLAGS"
+LDFLAGS="$ice_save_LDFLAGS"
+fi
+
+dnl Check for location of Tcl support
+dnl Disable Tcl support if not found
+
+dnl Check for tcl.h
+if test "$USE_TCL" = "true"
+then
+TCL_INCDIR=no
+AC_CHECK_HEADER(tcl.h, TCL_INCDIR=)
+for f in /usr/include /usr/include/tcl8.0 /usr/local/include /usr/local/include/tcl8.0; do
+if test "$TCL_INCDIR" = "no"; then
+AC_CHECK_HEADER($f/tcl.h, TCL_INCDIR=$f)
+fi
+done
+if test "$TCL_INCDIR" = "no"; then
+AC_MSG_WARN(tcl support disabled; tcl.h missing)
+USE_TCL=
+fi
+AC_SUBST(TCL_INCDIR)
+fi
+
+dnl Check for Tcl archive
+if test "$USE_TCL" = "true"
+then
+TCL_LIB=
+for f in tcl8.0 tcl80; do
+if test -z "$TCL_LIB"; then
+AC_CHECK_LIB($f, main, TCL_LIB=$f)
+fi
+done
+if test -z "$TCL_LIB"; then
+AC_MSG_WARN(tcl support disabled; Tcl library missing)
+USE_TCL=
+else
+TCL_LIB=-l$TCL_LIB
+fi
+AC_SUBST(TCL_LIB)
+fi
+
+dnl Check for location of Tk support (only if Tcl used)
+dnl Disable Tcl support if Tk not found
+
+dnl Check for tk.h
+if test "$USE_TCL" = "true"
+then
+
+ice_save_LIBS="$LIBS"
+ice_save_CFLAGS="$CFLAGS"
+ice_save_CPPFLAGS="$CPPFLAGS"
+ice_save_LDFLAGS="$LDFLAGS"
+
+CPPFLAGS="$CPPFLAGS $X_CFLAGS -I$TCL_INCDIR"
+
+TK_INCDIR=no
+AC_CHECK_HEADER(tk.h, TK_INCDIR=)
+for f in /usr/include /usr/include/tk8.0 /usr/local/include /usr/local/include/tk8.0; do
+if test "$TK_INCDIR" = "no"; then
+AC_CHECK_HEADER($f/tk.h, TK_INCDIR=$f)
+fi
+done
+if test "$TK_INCDIR" = "no"; then
+AC_MSG_WARN(tcl support disabled; tk.h missing)
+USE_TCL=
+fi
+AC_SUBST(TK_INCDIR)
+
+LIBS="$ice_save_LIBS"
+CFLAGS="$ice_save_CFLAGS"
+CPPFLAGS="$ice_save_CPPFLAGS"
+LDFLAGS="$ice_save_LDFLAGS"
+fi
+
+dnl Check for Tk archive
+if test "$USE_TCL" = "true"
+then
+TK_LIB=
+for f in tk8.0 tk80; do
+if test -z "$TK_LIB"; then
+AC_CHECK_LIB($f, main, TK_LIB=$f)
+fi
+done
+if test -z "$TK_LIB"; then
+AC_MSG_WARN(tcl support disabled; Tk library missing)
+USE_TCL=
+else
+TK_LIB=-l$TK_LIB
+fi
+AC_SUBST(TK_LIB)
+fi
 
 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/libpgtcl/Makefile interfaces/ecpg/lib/Makefile ) 

===========================================================================

--- Makefile.global.in.orig	Fri Feb 13 01:00:18 1998
+++ Makefile.global.in	Wed Feb 18 16:49:57 1998
@@ -160,18 +160,18 @@
 USE_TCL= @USE_TCL@
 # customize these to your site's needs
 #
-TCL_INCDIR= /usr/local/include
+TCL_INCDIR= @TCL_INCDIR@
 TCL_LIBDIR= /usr/local/lib
-TCL_LIB= -ltcl8.0
-TK_INCDIR= /usr/local/include
+TCL_LIB= @TCL_LIB@
+TK_INCDIR= @TK_INCDIR@
 TK_LIBDIR= /usr/local/lib
-TK_LIB= -ltk8.0
+TK_LIB= @TK_LIB@
 
 USE_PERL= @USE_PERL@
 
-X11_INCDIR= /usr/include
-X11_LIBDIR= /usr/lib
-X11_LIB= -lX11 @SOCKET_LIB@ @NSL_LIB@
+X_CFLAGS= @X_CFLAGS@
+X_LIBS= @X_LIBS@
+X11_LIBS= -lX11 @X_EXTRA_LIBS@
 
 
 ##############################################################################

===========================================================================

--- bin/pgtclsh/Makefile.orig	Mon Jan 26 01:00:49 1998
+++ bin/pgtclsh/Makefile	Wed Feb 18 16:05:03 1998
@@ -14,7 +14,7 @@
 SRCDIR= ../..
 include ../../Makefile.global
 
-CFLAGS+=  -I$(TCL_INCDIR) -I$(TK_INCDIR) -I$(X11_INCDIR) -I$(SRCDIR)/interfaces/libpgtcl
+CFLAGS+=  $(X_CFLAGS) -I$(TCL_INCDIR) -I$(TK_INCDIR) -I$(SRCDIR)/interfaces/libpgtcl
 
 ifdef KRBVERS
 LDFLAGS+= $(KRBLIBS)
@@ -33,8 +33,8 @@
 
 pgtksh: pgtkAppInit.o
 	$(CC) $(CFLAGS) -o $@ pgtkAppInit.o \
-	  $(LIBPGTCL) $(LIBPQ) -L$(TCL_LIBDIR) -L$(TK_LIBDIR) -L$(X11_LIBDIR) \
-	  $(TK_LIB) $(TCL_LIB) -lX11 -lm $(LDFLAGS)
+	  $(LIBPGTCL) $(LIBPQ) -L$(TCL_LIBDIR) -L$(TK_LIBDIR) $(X_LIBS) \
+	  $(TK_LIB) $(TCL_LIB) $(X11_LIBS) -lm $(LDFLAGS)
 
 install: pgtclsh pgtksh
 	$(INSTALL) $(INSTL_EXE_OPTS) pgtclsh $(DESTDIR)$(BINDIR)/pgtclsh
 

===========================================================================
===========================================================================
In check results, I found the -u (unified) diff option to make some of
the differences more intelligable.

--- test/regress/checkresults.orig	Tue Nov 25 15:07:18 1997
+++ test/regress/checkresults	Tue Feb 17 13:04:30 1998
@@ -7,7 +7,7 @@
 for file in `cat "$@" | grep 'failed$' | cut -d " " -f 1`
 do
 	echo "======   $file   ======"
-	diff -w expected/$file.out results
+	diff -uw expected/$file.out results
 done

Wed, 18 Feb 1998 20:18:12 -0700 (MST)
Brook Milligan <brook@trillium.NMSU.Edu>
a few patches for the upcoming 6.3 release
Applied, with autoconf.


> 
> In getting 6.3 working on a NetBSD/i386 box I have made up a few
> patches that correct some areas of the
> code/documentation/configuration.  They follow, each preceded by a
> description.  I hope they are useful; they allowed me to do a complete
> compilation using the --with-tcl configuration option, something I
> couldn't originally.
> 
> Cheers,
> Brook
> 
> ===========================================================================
> ===========================================================================
> 
> NOTE:  All patches originate at root_of_postgresql_tarball/src.
> 
> ===========================================================================
> ===========================================================================
> Documentation on at least these configure options is missing from INSTALL.
> 
> --- ../INSTALL.orig	Mon Feb  2 01:00:13 1998
> +++ ../INSTALL	Wed Feb 18 16:42:54 1998
> @@ -267,6 +267,15 @@
>                            listens for incoming connections on.  The
>                            default for this is port 5432.
>  
> +       --with-defaults    Use default responses to several queries during
> +                          configuration.
> +
> +       --with-tcl         Enables programs requiring Tcl/Tk and X11,
> +                          including pgtclsh and libpgtcl.
> +
> +       --with-perl        Enables the perl interface.  Note that this
> +                          requires an installed version of postgreSQL.
> +
>       As an example, here is the configure script I use on a Sparc
>       Solaris 2.5 system with /opt/postgres being the install base.
> 
> 
> ===========================================================================
> ===========================================================================
> I found that the configuration scripts were not looking for X11/tcl/tk
> support and the default built into Makefile.global.in was wrong for my
> system.  As a result using the --with-tcl bombed when it came to
> pgtclsh and libpgtcl.  The following three patches change the
> configuration system to search for X11/tcl/tk in various spots.  I
> hope all the relevant possibilities are included; it's easy to add new
> spots.  They also change the pgtclsh/Makefile to use the right
> variables set in Makefile.global.
> 
> Note that a new configure script will need to be made with autoconf if
> this patch is installed.
> 
> --- configure.in.orig	Tue Feb 17 01:00:36 1998
> +++ configure.in	Wed Feb 18 18:18:09 1998
> @@ -229,6 +229,7 @@
>  	USE_TCL=
>  fi
>  export USE_TCL
> +USE_X=$USE_TCL
>  
>  dnl We exclude perl support unless we override it with --with-perl
>  if test "X$with_perl" = "Xyes"
> @@ -514,5 +515,131 @@
>  AC_MSG_CHECKING(setting DEF_PGPORT)
>  AC_DEFINE_UNQUOTED(DEF_PGPORT, "${DEF_PGPORT}")
>  AC_MSG_RESULT($DEF_PGPORT)
> +
> +dnl Check for X libraries
> +
> +if test "$USE_X" = true; then
> +
> +ice_save_LIBS="$LIBS"
> +ice_save_CFLAGS="$CFLAGS"
> +ice_save_CPPFLAGS="$CPPFLAGS"
> +ice_save_LDFLAGS="$LDFLAGS"
> +
> +AC_PATH_XTRA
> +
> +LIBS="$LIBS $X_EXTRA_LIBS"
> +CFLAGS="$CFLAGS $X_CFLAGS"
> +CPPFLAGS="$CPPFLAGS $X_CFLAGS"
> +LDFLAGS="$LDFLAGS $X_LIBS"
> +
> +dnl Check for X library
> +
> +X11_LIBS=""
> +AC_CHECK_LIB(X11, XOpenDisplay, X11_LIBS="-lX11",,${X_PRE_LIBS})
> +if test "$X11_LIBS" = ""; then
> +dnl Not having X may be fatal.  Let the user fix this.
> +AC_MSG_WARN([The X11 library '-lX11' could not be found.
> +                    Please use the configure options '--x-includes=DIR'
> +                    and '--x-libraries=DIR' to specify the X location.
> +                    See the file 'config.log' for further diagnostics.])
> +fi
> +AC_SUBST(X_LIBS)
> +AC_SUBST(X11_LIBS)
> +AC_SUBST(X_PRE_LIBS)
> +
> +LIBS="$ice_save_LIBS"
> +CFLAGS="$ice_save_CFLAGS"
> +CPPFLAGS="$ice_save_CPPFLAGS"
> +LDFLAGS="$ice_save_LDFLAGS"
> +fi
> +
> +dnl Check for location of Tcl support
> +dnl Disable Tcl support if not found
> +
> +dnl Check for tcl.h
> +if test "$USE_TCL" = "true"
> +then
> +TCL_INCDIR=no
> +AC_CHECK_HEADER(tcl.h, TCL_INCDIR=)
> +for f in /usr/include /usr/include/tcl8.0 /usr/local/include /usr/local/include/tcl8.0; do
> +if test "$TCL_INCDIR" = "no"; then
> +AC_CHECK_HEADER($f/tcl.h, TCL_INCDIR=$f)
> +fi
> +done
> +if test "$TCL_INCDIR" = "no"; then
> +AC_MSG_WARN(tcl support disabled; tcl.h missing)
> +USE_TCL=
> +fi
> +AC_SUBST(TCL_INCDIR)
> +fi
> +
> +dnl Check for Tcl archive
> +if test "$USE_TCL" = "true"
> +then
> +TCL_LIB=
> +for f in tcl8.0 tcl80; do
> +if test -z "$TCL_LIB"; then
> +AC_CHECK_LIB($f, main, TCL_LIB=$f)
> +fi
> +done
> +if test -z "$TCL_LIB"; then
> +AC_MSG_WARN(tcl support disabled; Tcl library missing)
> +USE_TCL=
> +else
> +TCL_LIB=-l$TCL_LIB
> +fi
> +AC_SUBST(TCL_LIB)
> +fi
> +
> +dnl Check for location of Tk support (only if Tcl used)
> +dnl Disable Tcl support if Tk not found
> +
> +dnl Check for tk.h
> +if test "$USE_TCL" = "true"
> +then
> +
> +ice_save_LIBS="$LIBS"
> +ice_save_CFLAGS="$CFLAGS"
> +ice_save_CPPFLAGS="$CPPFLAGS"
> +ice_save_LDFLAGS="$LDFLAGS"
> +
> +CPPFLAGS="$CPPFLAGS $X_CFLAGS -I$TCL_INCDIR"
> +
> +TK_INCDIR=no
> +AC_CHECK_HEADER(tk.h, TK_INCDIR=)
> +for f in /usr/include /usr/include/tk8.0 /usr/local/include /usr/local/include/tk8.0; do
> +if test "$TK_INCDIR" = "no"; then
> +AC_CHECK_HEADER($f/tk.h, TK_INCDIR=$f)
> +fi
> +done
> +if test "$TK_INCDIR" = "no"; then
> +AC_MSG_WARN(tcl support disabled; tk.h missing)
> +USE_TCL=
> +fi
> +AC_SUBST(TK_INCDIR)
> +
> +LIBS="$ice_save_LIBS"
> +CFLAGS="$ice_save_CFLAGS"
> +CPPFLAGS="$ice_save_CPPFLAGS"
> +LDFLAGS="$ice_save_LDFLAGS"
> +fi
> +
> +dnl Check for Tk archive
> +if test "$USE_TCL" = "true"
> +then
> +TK_LIB=
> +for f in tk8.0 tk80; do
> +if test -z "$TK_LIB"; then
> +AC_CHECK_LIB($f, main, TK_LIB=$f)
> +fi
> +done
> +if test -z "$TK_LIB"; then
> +AC_MSG_WARN(tcl support disabled; Tk library missing)
> +USE_TCL=
> +else
> +TK_LIB=-l$TK_LIB
> +fi
> +AC_SUBST(TK_LIB)
> +fi
>  
>  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/libpgtcl/Makefile interfaces/ecpg/lib/Makefile ) 
> 
> ===========================================================================
> 
> --- Makefile.global.in.orig	Fri Feb 13 01:00:18 1998
> +++ Makefile.global.in	Wed Feb 18 16:49:57 1998
> @@ -160,18 +160,18 @@
>  USE_TCL= @USE_TCL@
>  # customize these to your site's needs
>  #
> -TCL_INCDIR= /usr/local/include
> +TCL_INCDIR= @TCL_INCDIR@
>  TCL_LIBDIR= /usr/local/lib
> -TCL_LIB= -ltcl8.0
> -TK_INCDIR= /usr/local/include
> +TCL_LIB= @TCL_LIB@
> +TK_INCDIR= @TK_INCDIR@
>  TK_LIBDIR= /usr/local/lib
> -TK_LIB= -ltk8.0
> +TK_LIB= @TK_LIB@
>  
>  USE_PERL= @USE_PERL@
>  
> -X11_INCDIR= /usr/include
> -X11_LIBDIR= /usr/lib
> -X11_LIB= -lX11 @SOCKET_LIB@ @NSL_LIB@
> +X_CFLAGS= @X_CFLAGS@
> +X_LIBS= @X_LIBS@
> +X11_LIBS= -lX11 @X_EXTRA_LIBS@
>  
>  
>  ##############################################################################
> 
> ===========================================================================
> 
> --- bin/pgtclsh/Makefile.orig	Mon Jan 26 01:00:49 1998
> +++ bin/pgtclsh/Makefile	Wed Feb 18 16:05:03 1998
> @@ -14,7 +14,7 @@
>  SRCDIR= ../..
>  include ../../Makefile.global
>  
> -CFLAGS+=  -I$(TCL_INCDIR) -I$(TK_INCDIR) -I$(X11_INCDIR) -I$(SRCDIR)/interfaces/libpgtcl
> +CFLAGS+=  $(X_CFLAGS) -I$(TCL_INCDIR) -I$(TK_INCDIR) -I$(SRCDIR)/interfaces/libpgtcl
>  
>  ifdef KRBVERS
>  LDFLAGS+= $(KRBLIBS)
> @@ -33,8 +33,8 @@
>  
>  pgtksh: pgtkAppInit.o
>  	$(CC) $(CFLAGS) -o $@ pgtkAppInit.o \
> -	  $(LIBPGTCL) $(LIBPQ) -L$(TCL_LIBDIR) -L$(TK_LIBDIR) -L$(X11_LIBDIR) \
> -	  $(TK_LIB) $(TCL_LIB) -lX11 -lm $(LDFLAGS)
> +	  $(LIBPGTCL) $(LIBPQ) -L$(TCL_LIBDIR) -L$(TK_LIBDIR) $(X_LIBS) \
> +	  $(TK_LIB) $(TCL_LIB) $(X11_LIBS) -lm $(LDFLAGS)
>  
>  install: pgtclsh pgtksh
>  	$(INSTALL) $(INSTL_EXE_OPTS) pgtclsh $(DESTDIR)$(BINDIR)/pgtclsh
>  
> 
> ===========================================================================
> ===========================================================================
> In check results, I found the -u (unified) diff option to make some of
> the differences more intelligable.
> 
> --- test/regress/checkresults.orig	Tue Nov 25 15:07:18 1997
> +++ test/regress/checkresults	Tue Feb 17 13:04:30 1998
> @@ -7,7 +7,7 @@
>  for file in `cat "$@" | grep 'failed$' | cut -d " " -f 1`
>  do
>  	echo "======   $file   ======"
> -	diff -w expected/$file.out results
> +	diff -uw expected/$file.out results
>  done
> 
> 


-- 
Bruce Momjian
maillist@candle.pha.pa.us

Sun, 22 Feb 1998 14:57:47 -0500 (EST)
Bruce Momjian <maillist@candle.pha.pa.us>
Re: [HACKERS] a few patches for the upcoming 6.3 release