[GRASS5] postgresql.m4 autoconf feature macro test

Eric G . Miller egm2 at jps.net
Fri Sep 15 02:29:32 EDT 2000


Here's a little PostgreSQL feature macro.  I appended it to an
aclocal.m4 in a test config env, and added these to Makefile.am:

PQINCPATH = @PQINCPATH@
PQLIB = @PQLIB@

Since GRASS currently doesn't use those, the subst variables can be put
in Makefile.in, and I suppose the macro can be added in aclocal.m4 at
the top directory. It's real simple and assumes libpq is in the default
search path.  ./config options could be added.  configure.in will need
POSTGRESQL_CHECKS on a line somewhere.  Anyway, it should work for most
standard configurations.

<postgresql.m4>
# Checks for libpq and libpq-fe.h, sets variables if found.
AC_DEFUN(POSTGRESQL_CHECKS, [
	AC_SUBST(PQINCPATH)
	AC_SUBST(PQLIB)

echo Checking if PostgreSQL is available

dnl Check for PQLIB first.
AC_CHECK_LIB(pq,PQconnectdb,FOUND_PQLIB=1)
if test $FOUND_PQLIB ; then
	PQLIB="-lpq"
else
	echo PostgreSQL library not found in default library path.
	exit 0
fi

dnl Check for PQINCPATH
if test -d /usr/include/pgsql ; then
	pg_inc_dir="/usr/include/pgsql"
elif test -d /usr/include/postgresql ; then
	pg_inc_dir="/usr/include/postgresql"
elif test -d /usr/local/psql/include ; then
	pg_inc_dir="/usr/local/psql/include"
elif test -d /opt/psql/include ; then
	pg_inc_dir="/opt/psql/include"
else
	echo PostgreSQL includes directory not found!
	PQLIB=""
	exit 0
fi

dnl Check for libpq-fe.h
AC_CHECK_HEADERS("$pg_inc_dir/libpq-fe.h")
if test $HAVE_HEADER-LIBPQ-FE.H ; then
	PQINCPATH="-I$pg_inc_dir"
else
	echo PostgreSQL header libpq-fe.h not found!
	PQLIB=""
	exit 0
fi

echo PostgreSQL configuration successful.
])
</postgresql.m4>

-- 
/bin/sh ~/.signature:
Command not found
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 232 bytes
Desc: not available
Url : http://lists.osgeo.org/pipermail/grass-dev/attachments/20000914/a98333b5/attachment.bin


More information about the grass-dev mailing list