Subject: Re: postgresql and dependancies.
To: None <tech-pkg@netbsd.org>
From: Greg A. Woods <woods@most.weird.com>
List: tech-pkg
Date: 10/06/1999 23:53:12
[ On Thursday, October 7, 1999 at 03:52:53 (+0200), Hubert Feyrer wrote: ]
> Subject: Re: postgresql and dependancies.
>
> at least for readline, i think it would be a win to have that in in any
> case. (i wonder if someone could whack the autoconf people into
> recognizing our readline lookalike). 

With a tiny fix to configure.in the following works rather well for
controlling readline support in postgres-6.5.1:

.if defined(USE_READLINE)
DEPENDS+=       readline-2.2:../../devel/readline
CONFIGURE_ARGS+= --enable-readline=yes
.else
CONFIGURE_ARGS+= --disable-readline
.endif
 
> for sfio, i don't know - if the package doesn't build without it, it sure
> should be added to the depends. if it utilizes sfio if it's there... no
> idea.

In my own postgresql-6.5.1 version of the package I patched configure.in
to remove the check for ncurses and sfio.  Here's the comment from my
Makefile:

# XXX sfio and ncurses support is patched out of the configure.in
# because otherwise it'll find them if you just happen to have the
# library installed and there's no way to turn it off (--without-LIB
# and --with-LIB=no do not work with AC_CHECK_LIB()).  I don't think
# either are a significant enough gain to actually require them all
# the time either (though sfio might be, but ncurses will just create
# administrative headaches for anyone not prepared to support it).
#
#DEPENDS+=      ncurses-1.9.9g:../../devel/ncurses
#DEPENDS+=      sfio-1998:../../devel/sfio

The complete configure.in patch is included below.  I can shar up the
entire pkgsrc module if anyone's interested (I do a couple of other
useful things to assist with upgrading on binary-only machines where the
database has to be unloaded and reloaded).

-- 
							Greg A. Woods

+1 416 218-0098      VE3TCP      <gwoods@acm.org>      <robohack!woods>
Planix, Inc. <woods@planix.com>; Secrets of the Weird <woods@weird.com>

--- configure.in.orig	Fri Apr  2 03:01:52 1999
+++ configure.in	Thu May 20 23:33:43 1999
@@ -451,6 +451,9 @@
     [   AC_PROG_CXX])
 AC_SUBST(HAVECXX)
 
+pg_cv_readline=yes
+AC_ARG_ENABLE(readline,[  --disable-readline      do not try to find and use the readline library],pg_cv_readline=$enableval)
+
 dnl Figure out how to invoke "install" and what install options to use.
 
 AC_PROG_INSTALL
@@ -540,15 +543,39 @@
 AC_SUBST(YACC)
 AC_SUBST(YFLAGS)
 
-AC_CHECK_LIB(sfio,     main)
-for curses in ncurses curses ; do
-	AC_CHECK_LIB(${curses}, main,
-		[LIBS="-l${curses} $LIBS"; break])
-done
+AC_CHECK_LIB(curses, main)
 AC_CHECK_LIB(termcap,  main)
-AC_CHECK_LIB(history,  main)
-AC_CHECK_LIB(readline, main)
-AC_CHECK_LIB(readline, write_history, AC_DEFINE(HAVE_HISTORY))
+
+# Readline must be listed before -lcurses and/or -ltermcap.
+if test "$pg_cv_readline" = yes ; then
+	READLINELIB=''
+	AC_CHECK_LIB(readline,readline,READLINELIB=readline)
+	if test "$READLINELIB" != "" ; then
+		if test "$CURSESLIB" != "" ; then
+			LIBS=`echo "$LIBS" | sed "s@$CURSESLIB@$READLINELIB -l$CURSESLIB@"`
+		elif test "$TERMCAPLIB" != "" ; then
+			LIBS=`echo "$LIBS" | sed "s@$TERMCAPLIB@$READLINELIB -l$TERMCAPLIB@"`
+		fi
+		AC_CHECK_HEADERS(readline.h history.h )
+		AC_CHECK_HEADERS(readline/readline.h readline/history.h)
+		AC_CHECK_LIB(readline, write_history, AC_DEFINE(HAVE_HISTORY))
+	fi
+else
+	ac_cv_lib_readline=no
+fi
+
+if test "$ac_cv_lib_readline" = yes ; then
+	# Make sure we link termcap with readline if we aren't already
+	# linking curses or termcap.
+	case "$LIBS" in
+		*termcap*|*curses*)
+			;;
+		*)
+			LIBS="$LIBS -ltermcap"
+			;;
+	esac
+fi
+
 if test "$PORTNAME" != "aix" -a "$PORTNAME" != "alpha"
 then
 	AC_CHECK_LIB(bsd,      main)
@@ -574,8 +601,8 @@
 AC_HEADER_SYS_WAIT
 AC_CHECK_HEADERS(limits.h unistd.h termios.h values.h sys/select.h)
 AC_CHECK_HEADERS(sys/resource.h netdb.h arpa/inet.h getopt.h)
-AC_CHECK_HEADERS(readline.h history.h dld.h crypt.h endian.h float.h)
-AC_CHECK_HEADERS(readline/readline.h readline/history.h ieeefp.h fp_class.h)
+AC_CHECK_HEADERS(dld.h crypt.h endian.h float.h)
+AC_CHECK_HEADERS(ieeefp.h fp_class.h)
 AC_CHECK_HEADERS(netinet/in.h string.h strings.h)
 dnl ODBC headers...
 AC_CHECK_HEADERS(sys/param.h pwd.h)
@@ -998,7 +1025,7 @@
 dnl If --with-tclconfig was given, don't check for tclsh, tcl
 if test -z "$TCL_DIRS"
 then
-	AC_PATH_PROG(TCLSH, tclsh)
+	AC_PATH_PROG(TCLSH, tclsh8.0)
 	if test -z "$TCLSH"
 	then
 		AC_PATH_PROG(TCLSH, tcl)
@@ -1046,9 +1073,9 @@
 	# library_dirs are set in the check for TCL
 	for dir in $library_dirs
 	do
-		if test -d "$dir" -a -r "$dir/tkConfig.sh"
+		if test -d "$dir" -a -r "$dir/../tk8.0/tkConfig.sh"
 		then
-			TK_CONFIG_SH=$dir/tkConfig.sh
+			TK_CONFIG_SH=$dir/../tk8.0/tkConfig.sh
 			break
 		fi
 	done