Here are 3 patches (all relative to the src directory) to help with
the configuration of v6.3.1.  I have replaced the queries for
include/lib directories with --with configuration options.  I have
also included a list of potential tcl/tk include directories directly
in the CPPFLAGS variable.  As new versions are needed, these should be
added to the list in reverse numerical order (libraries are in a
separate list near the end).  This greatly simplifies the later checks
if --with-tcl is set.  I hope this solution works for everyone.  

I also added a check to disable the perl support if postgres was not
already installed (as per the instructions in the directory).  By the
way, why must there be an installed pgsql to compile perl support?
This seems odd, at best.

Finally, I changed the Makefile in the libpgtcl interface to place the
shared libraries at the end of the list of files, not at the
beginning.  With NetBSD at least, libraries are linked in order, so
the original sequence does not work.

Hope you find these useful.

Cheers,
Brook

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

--- configure.in.orig	Mon Mar 23 07:33:33 1998
+++ configure.in	Fri Apr  3 15:32:42 1998
@@ -141,62 +141,47 @@
 LIBS=`grep '^LIBS:' $TEMPLATE | awk -F: '{print $2}'`
 
 
-dnl We now need to check for additional directories (include
-dnl and library directories.
-echo "**************************************************************"
-echo "We now need to know if your compiler needs to search any
-echo "additional directories for include or library files.  If
-echo "you don't know the answers to these questions, then just
-echo "hit enter and we will try and figure it out.  If things
-echo "don't compile because of missing libraries or include
-echo "files, then you probably need to enter something here.
-echo "enter 'none' or new directories to override default"
-echo ""
-$ECHO_N "Additional directories to search for include files { $SRCH_INC }: $ECHO_C"
-if test "X$with_defaults" = "Xyes"
-then
-	a=$SRCH_INC
-	echo ""
-else
-	read a
+AC_ARG_WITH(includes,
+    [  --with-includes=DIR    site header files for tk/tcl, etc in DIR],
+    [
+	case "$withval" in
+	"" | y | ye | yes | n | no)
+	    AC_MSG_ERROR([*** You must supply an argument to the --with-includes option.])
+	  ;;
+	esac
+	INCLUDE_DIRS="$withval"
+    ])
+
+if test "$INCLUDE_DIRS"; then
+	for dir in $INCLUDE_DIRS; do
+	    if test -d "$dir"; then
+		PGSQL_CPPFLAGS="$PGSQL_CPPFLAGS -I$dir"
+	    else
+		AC_MSG_WARN([*** Include directory $dir does not exist.])
+	    fi
+	done
+fi
+
+AC_ARG_WITH(libraries,
+    [  --with-libraries=DIR   site library directories for tk/tcl, etc in DIR],
+    [
+	case "$withval" in
+	"" | y | ye | yes | n | no)
+	    AC_MSG_ERROR([*** You must supply an argument to the --with-libraries option.])
+	  ;;
+	esac
+	LIBRARY_DIRS="$withval"
+    ])
+
+if test "$LIBRARY_DIRS"; then
+	for dir in $withval; do
+	    if test -d "$dir"; then
+		PGSQL_LDFLAGS="$PGSQL_LDFLAGS -L$dir"
+	    else
+		AC_MSG_WARN([*** Library directory $dir does not exist.])
+	    fi
+	done
 fi
-if test "$a." = "none." 
-then
-	SRCH_INC=
-	CPPFLAGS=
-else
-	if test "$a." = "."
-	then
-		a=$SRCH_INC
-	fi
-	CPPFLAGS=`echo "$a" | sed 's@  *@ @g; s@^\([[^ ]]\)@-I\1@; s@ \([[^ ]]\)@ -I\1@g'`
-
-fi
-export CPPFLAGS
-echo "- setting CPPFLAGS=$CPPFLAGS"
-
-$ECHO_N "Additional directories to search for library files { $SRCH_LIB }: $ECHO_C"
-if test "X$with_defaults" = "Xyes"
-then
-	a=$SRCH_LIB
-	echo ""
-else
-	read a
-fi
-if test "$a." = "none."
-then
-	SRCH_LIB=
-	LDFLAGS=
-else
-	if test "$a." = "."
-	then
-		a=$SRCH_LIB
-	fi
-	LDFLAGS=`echo "$a" | sed 's@  *@ @g; s@^\([[^ ]]\)@-L\1@; s@ \([[^ ]]\)@ -L\1@g'`
-
-fi
-export LDFLAGS
-echo "- setting LDFLAGS=$LDFLAGS"
 
 dnl We have read the default value of USE_LOCALE from the template 
 dnl file.  We have a further option of using 
@@ -242,6 +227,27 @@
    USE_TCL=true; AC_MSG_RESULT(enabled),
    USE_TCL=false; AC_MSG_RESULT(disabled)
 )
+
+dnl Add tcl/tk candidate directories to CPPFLAGS
+if test "$USE_TCL"; then
+	header_dirs="/usr/include $INCLUDE_DIRS"
+	tcl_dirs="tcl8.0 tcl80 tcl7.6 tcl76"
+	tk_dirs="tk8.0 tk4.2"
+	for dir in $header_dirs; do
+	    for tcl_dir in $tcl_dirs; do
+		if test -d "$dir/$tcl_dir"; then
+		    PGSQL_CPPFLAGS="$PGSQL_CPPFLAGS -I$dir/$tcl_dir"
+		fi
+	    done
+	done
+	for dir in $header_dirs; do
+	    for tk_dir in $tk_dirs; do
+		if test -d "$dir/$tk_dir"; then
+		    PGSQL_CPPFLAGS="$PGSQL_CPPFLAGS -I$dir/$tk_dir"
+		fi
+	    done
+	done
+fi
 export USE_TCL
 USE_X=$USE_TCL
 
@@ -253,6 +259,15 @@
    USE_PERL=true; AC_MSG_RESULT(enabled),
    USE_PERL=false; AC_MSG_RESULT(disabled)
 )
+
+dnl Verify that postgres is already installed
+dnl per instructions for perl interface installation
+if test "$USE_PERL" = "true"; then
+	if test ! -x $prefix/bin/postgres; then
+	    AC_MSG_WARN(perl support disabled; postgres not previously installed)
+	    USE_PERL=
+	fi
+fi
 export USE_PERL
 
 dnl Unless we specify the command line options
@@ -276,6 +291,13 @@
         AC_PROG_CC
 fi
 
+CPPFLAGS="$CPPFLAGS $PGSQL_CPPFLAGS"
+export CPPFLAGS
+echo "- setting CPPFLAGS=$CPPFLAGS"
+
+LDFLAGS="$LDFLAGS $PGSQL_LDFLAGS"
+export LDFLAGS
+echo "- setting LDFLAGS=$LDFLAGS"
 
 AC_CONFIG_HEADER(include/config.h)
 
@@ -571,17 +593,21 @@
 fi
 
 dnl Check for Tcl archive
-if test "$USE_TCL" = "true"
-then
-TCL_LIB=
-AC_CHECK_LIB(tcl, main, TCL_LIB=tcl)
-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)
+if test "$USE_TCL" = "true"; then
+	TCL_LIB=
+	tcl_libs="tcl8.0 tcl80 tcl7.6 tcl76 tcl"
+	for tcl_lib in $tcl_libs; do
+	    if test -z "$TCL_LIB"; then
+		AC_CHECK_LIB($tcl_lib, main, TCL_LIB=$tcl_lib)
+	    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)
@@ -612,17 +638,21 @@
 fi
 
 dnl Check for Tk archive
-if test "$USE_TCL" = "true"
-then
-TK_LIB=
-AC_CHECK_LIB(tk, main, TK_LIB=tk)
-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)
+if test "$USE_TCL" = "true"; then
+	TK_LIB=
+	tk_libs="tk8.0 tk80 tk4.2 tk42 tk"
+	for tk_lib in $tk_libs; do
+	    if test -z "$TK_LIB"; then
+		AC_CHECK_LIB($tk_lib, main, TK_LIB=$tk_lib)
+	    fi
+	done
+	if test -z "$TK_LIB"; then
+	    AC_MSG_WARN(tk 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 ) 

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

--- ../INSTALL.orig	Sun Feb 22 13:02:06 1998
+++ ../INSTALL	Fri Apr  3 11:57:04 1998
@@ -267,14 +267,21 @@
                           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.
+
+       --with-includes=DIRS
+                          Include DIRS in list of directories searched
+                          for header files.  (Typical use will need
+                          --with-includes=/usr/local/include)
+
+       --with-libraries=DIRS
+                          Include DIRS in list of directories searched
+                          for archive libraries.  (Typical use will need
+                          --with-libraries=/usr/local/lib)
 
      As an example, here is the configure script I use on a Sparc
      Solaris 2.5 system with /opt/postgres being the install base.

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

--- interfaces/libpgtcl/Makefile.in.orig	Mon Mar 23 07:33:35 1998
+++ interfaces/libpgtcl/Makefile.in	Fri Apr  3 11:13:52 1998
@@ -31,12 +31,14 @@
 install-shlib-dep :=
 shlib             := 
 
+LIBPQ			= -L $(SRCDIR)/interfaces/libpq -lpq
+
 ifeq ($(PORTNAME), linux)
   ifdef LINUX_ELF
     install-shlib-dep	:= install-shlib
     shlib		:= libpgtcl.so.1
     CFLAGS		+= $(CFLAGS_SL)
-    LDFLAGS_SL		= -shared -L$(SRCDIR)/interfaces/libpq -lpq
+    LDFLAGS_SL		= -shared
   endif
 endif
 
@@ -52,14 +54,14 @@
 ifeq ($(PORTNAME), i386_solaris)
   install-shlib-dep	:= install-shlib
   shlib			:= libpgtcl.so.1
-  LDFLAGS_SL		= -G -z text -L$(SRCDIR)/interfaces/libpq -lpq
+  LDFLAGS_SL		= -G -z text
   CFLAGS		+= $(CFLAGS_SL)
 endif
 
 ifeq ($(PORTNAME), univel)
   install-shlib-dep	:= install-shlib
   shlib			:= libpgtcl.so.1
-  LDFLAGS_SL		= -G -z text -L$(SRCDIR)/interfaces/libpq -lpq
+  LDFLAGS_SL		= -G -z text
   CFLAGS		+= $(CFLAGS_SL)
 endif
 
@@ -77,7 +79,7 @@
 	$(RANLIB) libpgtcl.a
 
 $(shlib): $(OBJS)
-	$(LD) $(LDFLAGS_SL) -o $@ $(OBJS) 
+	$(LD) $(LDFLAGS_SL) -o $@ $(OBJS) $(LIBPQ)
 	ln -sf $@ libpgtcl.so
 
 .PHONY: beforeinstall-headers install-headers

Fri, 3 Apr 1998 21:34:22 -0700 (MST)
Brook Milligan <brook@trillium.NMSU.Edu>
configuration patches
> 
> Here are 3 patches (all relative to the src directory) to help with
> the configuration of v6.3.1.  I have replaced the queries for
> include/lib directories with --with configuration options.  I have
> also included a list of potential tcl/tk include directories directly
> in the CPPFLAGS variable.  As new versions are needed, these should be
> added to the list in reverse numerical order (libraries are in a
> separate list near the end).  This greatly simplifies the later checks
> if --with-tcl is set.  I hope this solution works for everyone.  
> 
> I also added a check to disable the perl support if postgres was not
> already installed (as per the instructions in the directory).  By the
> way, why must there be an installed pgsql to compile perl support?
> This seems odd, at best.
> 
> Finally, I changed the Makefile in the libpgtcl interface to place the
> shared libraries at the end of the list of files, not at the
> beginning.  With NetBSD at least, libraries are linked in order, so
> the original sequence does not work.
> 
> Hope you find these useful.
> 

Applied.  These will be very tempting for Marc, because it improves
automatic tcl/tk include/library search support.


-- 
Bruce Momjian                          |  830 Blythe Avenue
maillist@candle.pha.pa.us              |  Drexel Hill, Pennsylvania 19026
  +  If your life is a hard drive,     |  (610) 353-9879(w)
  +  Christ can be your backup.        |  (610) 853-3000(h)

Sun, 5 Apr 1998 16:26:33 -0400 (EDT)
Bruce Momjian <maillist@candle.pha.pa.us>
Re: [HACKERS] configuration patches