From f6c4c72e6a8abd4ac7b883b857bcffd68191ab77 Mon Sep 17 00:00:00 2001
From: Francesco Chemolli <li@kinkie.it>
Date: Mon, 2 Feb 1998 19:30:48 +0100
Subject: [PATCH] Updated to 1.0.2.

Rev: src/modules/Postgres/ChangeLog:1.4
Rev: src/modules/Postgres/configure.in:1.5
Rev: src/modules/Postgres/version.h:1.3
---
 src/modules/Postgres/ChangeLog    | 72 +++++++++---------------------
 src/modules/Postgres/configure.in | 74 +++++++++++++++++++++++++++----
 src/modules/Postgres/version.h    |  4 +-
 3 files changed, 87 insertions(+), 63 deletions(-)

diff --git a/src/modules/Postgres/ChangeLog b/src/modules/Postgres/ChangeLog
index f9d6a3ef74..58aee87a1d 100644
--- a/src/modules/Postgres/ChangeLog
+++ b/src/modules/Postgres/ChangeLog
@@ -1,4 +1,17 @@
-Mon Dec 15 14:33:50 1997  Francesco Chemolli  <kinkie@ai-chan>
+Sat Jan 31 18:50:03 1998  Francesco Chemolli  <kinkie@ai-chan>
+
+	* configure.in, ChangeLog, configure:
+	Added locate-based last ditch for libraries
+
+	* configure.in, configure:
+	Added locate-based last ditch for include files
+	Added arguments to allow the user specify include- and lib-directories.
+
+Mon Dec 15 21:40:36 1997  Francesco Chemolli  <kinkie@ai-chan>
+
+	* configure.in, configure: Added some extra include-paths (at last).
+
+	* ChangeLog, version.h: Released version 1.0.1
 
 	* postgres.c:
 	Changed error message upon failed connection to be more verbose, since
@@ -21,21 +34,6 @@ Tue Nov 25 16:12:37 1997  Francesco Chemolli  <kinkie@ai-chan>
 
 	* lib/postgres.pike: Fixed a typo.
 
-Tue Nov 25 13:42:25 1997  Francesco Chemolli  <kinkie@ai-chan>
-
-	* version.h: Released version 1.0 (hopefully)
-
-	* doc/Attic/raw_postgres, doc/sql_postgres, doc/sql_postgres_result, 
-	  doc/Attic/postgres, doc/Attic/postgres_result, doc/postgres_postgres, 
-		doc/postgres_postgres_result:
-	Made some order, to make the documentation better understandable and
-	complete.
-
-	* doc/Attic/postgres, doc/Attic/postgres_result, doc/Attic/raw_postgres:
-	Fixed and completed the documentation.
-
-	* lib/postgres.pike: Fixed a typo.
-
 Mon Nov 24 14:34:31 1997  Francesco Chemolli  <kinkie@ai-chan>
 
 	* lib/postgres.h:
@@ -53,15 +51,6 @@ Mon Nov 24 14:34:31 1997  Francesco Chemolli  <kinkie@ai-chan>
 
 	* lib/postgres.h: *** empty log message ***
 
-Mon Nov 24 14:32:49 1997  Francesco Chemolli  <kinkie@ai-chan>
-
-	* lib/postgres.pike: Added interface compliancy for list_fields.
-
-	* doc/postgres, doc/postgres_result:
-	Documentation. Lots of it (I hope).
-
-	* lib/Attic/postgres.h: *** empty log message ***
-
 Thu Nov 13 10:53:39 1997  Francesco Chemolli  <kinkie@ai-chan>
 
 	* ChangeLog: *** empty log message ***
@@ -85,32 +74,17 @@ Sun Oct 12 13:11:37 1997  Francesco Chemolli  <kinkie@ai-chan>
 
 	Stronger typechecking for create().
 
-Sun Oct 12 13:10:08 1997  Francesco Chemolli  <kinkie@ai-chan>
-
-	* lib/postgres.pike: Removed some redundant code for create().
-
-	* postgres.c:
-	Better argument handling for create(). Now portnumber 0 is a special
-	case which means "default port" and leaves to the pglib the burden
-	of determining the port to connect to.
-	Now finally 'object o=Sql.postgres()' works (previously it misbehaved
-	if the database argument was missing).
-
-	Stronger typechecking for create().
-
 	* lib/postgres.pike:
 	Changes were made to use better SQL queries instead of
 	filtering the results by hand.
 
-	* Released version 0.7
+Mon Oct  6 18:01:06 1997  Francesco Chemolli  <kinkie@ai-chan>
 
-Mon Oct  6 17:55:15 1997  Francesco Chemolli  <kinkie@ai-chan>
+	* ChangeLog: *** empty log message ***
 
 	* postgres.c: Adopted xalloc in lieu of malloc for increased safety
 	Added a "version" constant to the postgres pike module to identify
-	the vesion with more ease. I'll leave it undocumented elsewhere though.
-
-	* Released version 0.6
+	 the vesion with more ease. I'll leave it undocumented elsewhere though.
 
 Sat Sep  6 11:26:53 1997  Francesco Chemolli  <kinkie@ai-chan>
 
@@ -124,8 +98,6 @@ Tue Jul  8 20:23:06 1997  Francesco Chemolli  <kinkie@ai-chan>
 	Corrected a small bug which manifested itself when building in a
 	non_threaded environment.
 
-	* Released version 0.5
-
 Mon Jun 30 13:57:08 1997  Francesco Chemolli  <kinkie@ai-chan>
 
 	* configure.in, postgres.c, configure:
@@ -144,7 +116,7 @@ Mon Jun 30 13:57:08 1997  Francesco Chemolli  <kinkie@ai-chan>
 
 Fri Jun 27 09:55:51 1997  Francesco Chemolli  <kinkie@ai-chan>
 
-	* quickmanual.txt: Quickmanual.txt: aggiornata la documentazione
+	* Attic/quickmanual.txt: Quickmanual.txt: aggiornata la documentazione
 
 	* lib/postgres.pike: Postgres.pike:
 	- modificato in modo da gestire l'interfaccia con meno argomenti di
@@ -161,8 +133,6 @@ Fri Jun 27 09:55:51 1997  Francesco Chemolli  <kinkie@ai-chan>
 	proprietaria ma semplice. Ci pensera` poi il modulo di interfaccia a
 	gestire la traduzione e a ottenere la compliancy.
 
-	* Released version 0.4
-
 Thu Jun 19 12:35:12 1997  Francesco Chemolli  <kinkie@ai-chan>
 
 	* lib/postgres.pike: Corretto un baco in lib/postgres.pike
@@ -178,14 +148,12 @@ Thu Jun 19 12:35:12 1997  Francesco Chemolli  <kinkie@ai-chan>
 	Ora la classe in Sql.pmod puo` ereditare. Piu` efficiente, e migliore
 	controllo degli errori.
 
-	* Released version 0.3
-
 Wed Apr  2 11:56:14 1997  Francesco Chemolli  <kinkie@ai-chan>
 
-	* Makefile.in, configure, configure.in, extras/test_notify.pike, extras/test_schema.pike, lib/postgres.h, pg_types.h, pgres_config.h.in, pgresult.c, postgres.c, quickmanual.txt, testsuite.in:
+	* Attic/quickmanual.txt, Makefile.in, configure, configure.in, extras/test_notify.pike, extras/test_schema.pike, lib/postgres.h, pg_types.h, pgres_config.h.in, pgresult.c, postgres.c, testsuite.in:
 	Initial revision
 
-	* Makefile.in, configure, configure.in, extras/test_notify.pike, extras/test_schema.pike, lib/postgres.h, pg_types.h, pgres_config.h.in, pgresult.c, postgres.c, quickmanual.txt, testsuite.in:
+	* Attic/quickmanual.txt, Makefile.in, configure, configure.in, extras/test_notify.pike, extras/test_schema.pike, lib/postgres.h, pg_types.h, pgres_config.h.in, pgresult.c, postgres.c, testsuite.in:
 	Initial version of the Postgres module for Pike.
 	Apparently working.
 
diff --git a/src/modules/Postgres/configure.in b/src/modules/Postgres/configure.in
index e8fa182e07..239f1253f0 100644
--- a/src/modules/Postgres/configure.in
+++ b/src/modules/Postgres/configure.in
@@ -1,4 +1,4 @@
-dnl $Id: configure.in,v 1.4 1998/01/30 17:41:43 grubba Exp $
+dnl $Id: configure.in,v 1.5 1998/02/02 18:30:48 grubba Exp $
 dnl (C) 1997 Francesco Chemolli <kinkie@comedia.it>
 
 AC_INIT(postgres.c)
@@ -6,8 +6,15 @@ AC_CONFIG_HEADER(pgres_config.h)
 
 echo "Configuring Postgres module, (C) 1997 Francesco Chemolli <kinkie@comedia.it>"
 
-AC_ARG_WITH(postgres,[  --with(out)-postgres  postgres95 DB server support],
+AC_ARG_WITH(postgres,
+	[  --with(out)-postgres               postgres95 DB server support],
 	[],[with_postgres=yes])
+AC_ARG_WITH(postgres-include-dir, 
+	[  --with-postgres-include-dir=dir    look for header-files in dir],
+	[pike_postgres_user_include_directory=$withval])
+AC_ARG_WITH(libpq-dir, 
+	[  --with-libpq-dir=dir               look for library-files in dir],
+	[pike_postgres_user_lib_directory=$withval])
 
 sinclude(../module_configure.in)
 
@@ -15,8 +22,8 @@ ac_pike_postgres_skip=no
 
 dnl set up "reasonable" search paths
 pike_postgres_reasonable_prefixes="/usr/local /usr /opt /usr/lib"
-pike_postgres_reasonable_directories="postgres95 postgres pgsql /"
-pike_postgres_extra_include_directories="$HOME/include /usr/include/postgres95 /usr/include/postgres /usr/lib/pgsql/include"
+pike_postgres_reasonable_directories="postgres95 postgres pgsql ."
+pike_postgres_extra_include_directories="$HOME/include /usr/include/postgres95 /usr/include/pgsql /usr/include/postgres /usr/lib/pgsql/include"
 pike_postgres_extra_lib_directories="$HOME/lib /usr/lib/pgsql/lib"
 
 for a in $pike_postgres_reasonable_prefixes
@@ -27,8 +34,15 @@ do
 		pike_postgres_reasonable_lib_searchpath="$pike_postgres_reasonable_lib_searchpath $a/$b/lib"
 	done
 done
-pike_postgres_reasonable_include_searchpath="$pike_postgres_reasonable_include_searchpath $pike_postgres_extra_include_directories"
-pike_postgres_reasonable_lib_searchpath="$pike_postgres_reasonable_lib_searchpath $pike_postgres_extra_lib_directories"
+pike_postgres_reasonable_include_searchpath="$pike_postgres_user_include_directory $pike_postgres_reasonable_include_searchpath $pike_postgres_extra_include_directories"
+pike_postgres_reasonable_lib_searchpath="$pike_postgres_user_lib_directory $pike_postgres_reasonable_lib_searchpath $pike_postgres_extra_lib_directories"
+
+dnl check for dirname and locate, we might need them
+AC_CHECK_PROG(dirname,dirname,yes)
+AC_CHECK_PROG(locate,locate,yes)
+if test x$ac_cv_prog_dirname$ac_cv_prog_locate = xyesyes; then
+	pike_cv_can_try_locate=yes
+fi
 
 dnl start actual work
 if test x$with_postgres = xyes; then
@@ -36,11 +50,12 @@ if test x$with_postgres = xyes; then
 	OLD_LIBS=$LIBS
 	OLD_LDFLAGS=$LDFLAGS
 
+dnl see if we can find the include files in any of the standard locations
 	AC_MSG_CHECKING(for location of the Postgres include files)
 	AC_CACHE_VAL(pike_cv_pgres_include_dir, [
 		for pike_cv_pgres_include_dir in $pike_postgres_reasonable_include_searchpath no
 			do
-				if test -f $pike_cv_pgres_include_dir/postgres.h; then
+				if test -f $pike_cv_pgres_include_dir/libpq-fe.h; then
 					break
 				fi
 			done
@@ -50,22 +65,47 @@ if test x$with_postgres = xyes; then
 	else
 		AC_MSG_RESULT(not found.)
 	fi
+
+dnl last ditch. The locator could be confused e.g. by pike include files
+dnl unluckily there's no way out of it.
+	if test x$pike_cv_pgres_include_dir$pike_cv_can_try_locate = xnoyes; then
+		AC_MSG_CHECKING(whether we can locate it anyway...)
+		for pike_cv_pgres_locate_include_file in `locate libpq-fe.h`
+			do
+dnl check it not to be a stale entry
+				if test -f $pike_cv_pgres_locate_include_file; then
+					pike_cv_pgres_include_dir=`dirname $pike_cv_pgres_locate_include_file`
+					break
+				fi
+			done
+		if test x$pike_cv_pgres_include_dir != xno; then
+			AC_MSG_RESULT(found in $pike_cv_pgres_include_dir.)
+		else
+			AC_MSG_RESULT(not found.)
+		fi
+	fi
+
 	if test x$pike_cv_pgres_include_dir != xno; then
 		CPPFLAGS="$CPPFLAGS -I$pike_cv_pgres_include_dir"
 	fi
+
+dnl final ckeck, just to be sure we didn't mess up
 	AC_CHECK_HEADERS(postgres.h)
 	AC_CHECK_HEADERS(libpq-fe.h)
-	if test x$ac_cv_header_libpq_fe_h = xno ; then
+	if test x$ac_cv_header_libpq_fe_h$ac_cv_header_postgres_h != xyesyes ; then
+		ac_cv_header_libpq_fe_h=no
 		ac_cv_header_postgres_h=no
 		ac_pike_postgres_skip=yes
 	fi
 
+dnl okay, now let's start working on the libraries
 	if test x$ac_pike_postgres_skip = xno; then
 		AC_MSG_CHECKING(for location of the Postgres library)
 		AC_CACHE_VAL(pike_cv_pgres_lib_dir,[
 			for pike_cv_pgres_lib_dir in $pike_postgres_reasonable_lib_searchpath no
 			do
-				if test -f $pike_cv_pgres_lib_dir/libpq.a; then
+				if test -f $pike_cv_pgres_lib_dir/libpq.a -o \
+					-f $pike_cv_pgres_lib_dir/libpq.so; then
 					break
 				fi
 			done
@@ -75,6 +115,22 @@ if test x$with_postgres = xyes; then
 		else
 			AC_MSG_RESULT(not found.)
 		fi
+		if test x$pike_cv_pgres_lib_dir$pike_cv_can_try_locate = xnoyes; then
+			AC_MSG_CHECKING(whether we can locate it anyway)
+			for pike_cv_pgres_locate_lib_file in `locate libpq.so libpq.a`
+				do
+					if test -f $pike_cv_pgres_locate_lib_file; then
+						pike_cv_pgres_lib_dir=`dirname $pike_cv_pgres_locate_lib_file`
+					fi
+				done
+			if test x$pike_cv_pgres_lib_dir != xno; then
+				AC_MSG_RESULT(found in $pike_cv_pgres_lib_dir.)
+			else
+				AC_MSG_RESULT(not found.)
+			fi
+		fi
+
+dnl last check, just to be sure
 		if test x$pike_cv_pgres_lib_dir != xno; then
 			LDFLAGS="$LDFLAGS -L$pike_cv_pgres_lib_dir"
 		fi
diff --git a/src/modules/Postgres/version.h b/src/modules/Postgres/version.h
index 08f050aa53..01eebfee15 100644
--- a/src/modules/Postgres/version.h
+++ b/src/modules/Postgres/version.h
@@ -1,8 +1,8 @@
 /*
- * $Id: version.h,v 1.2 1997/12/16 15:55:21 grubba Exp $
+ * $Id: version.h,v 1.3 1998/02/02 18:30:48 grubba Exp $
  *
  * This file is provided for CVS's sake, and to define a simple string to be
  * used as the module's release version
  */
 
-#define PGSQL_VERSION "Postgres/1.0.1"
+#define PGSQL_VERSION "Postgres/1.0.2"
-- 
GitLab