1
dnl @synopsis AX_LIB_POSTGRESQL([MINIMUM-VERSION])
3
dnl This macro provides tests of availability of PostgreSQL 'libpq'
4
dnl library of particular version or newer.
6
dnl AX_LIB_POSTGRESQL macro takes only one argument which is optional.
7
dnl If there is no required version passed, then macro does not run
10
dnl The --with-postgresql option takes one of three possible values:
12
dnl no - do not check for PostgreSQL client library
14
dnl yes - do check for PostgreSQL library in standard locations
15
dnl (pg_config should be in the PATH)
17
dnl path - complete path to pg_config utility, use this option if
18
dnl pg_config can't be found in the PATH
22
dnl AC_SUBST(POSTGRESQL_CFLAGS)
23
dnl AC_SUBST(POSTGRESQL_LDFLAGS)
24
dnl AC_SUBST(POSTGRESQL_VERSION)
30
dnl @category InstalledPackages
32
dnl @author Mateusz Loskot <mateusz@loskot.net>
33
dnl @version 2006-07-16
34
dnl @license AllPermissive
36
AC_DEFUN([AX_LIB_POSTGRESQL],
38
AC_ARG_WITH([postgresql],
39
AC_HELP_STRING([--with-postgresql=@<:@ARG@:>@],
40
[use PostgreSQL library @<:@default=yes@:>@, optionally specify path to pg_config]
43
if test "$withval" = "no"; then
45
elif test "$withval" = "yes"; then
52
[want_postgresql="yes"]
57
POSTGRESQL_POSTGRESQL=""
60
dnl Check PostgreSQL libraries (libpq)
63
if test "$want_postgresql" = "yes"; then
65
if test -z "$PG_CONFIG" -o test; then
66
AC_PATH_PROG([PG_CONFIG], [pg_config], [no])
69
if test "$PG_CONFIG" != "no"; then
70
AC_MSG_CHECKING([for PostgreSQL libraries])
72
POSTGRESQL_CFLAGS="-I`$PG_CONFIG --includedir`"
73
POSTGRESQL_LDFLAGS="-L`$PG_CONFIG --libdir` -lpq"
75
POSTGRESQL_VERSION=`$PG_CONFIG --version | sed -e 's#PostgreSQL ##'`
77
AC_DEFINE([HAVE_POSTGRESQL], [1],
78
[Define to 1 if PostgreSQL libraries are available])
80
found_postgresql="yes"
89
dnl Check if required version of PostgreSQL is available
93
postgresql_version_req=ifelse([$1], [], [], [$1])
95
if test "$found_postgresql" = "yes" -a -n "$postgresql_version_req"; then
97
AC_MSG_CHECKING([if PostgreSQL version is >= $postgresql_version_req])
99
dnl Decompose required version string of PostgreSQL
100
dnl and calculate its number representation
101
postgresql_version_req_major=`expr $postgresql_version_req : '\([[0-9]]*\)'`
102
postgresql_version_req_minor=`expr $postgresql_version_req : '[[0-9]]*\.\([[0-9]]*\)'`
103
postgresql_version_req_micro=`expr $postgresql_version_req : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'`
104
if test "x$postgresql_version_req_micro" = "x"; then
105
postgresql_version_req_micro="0"
108
postgresql_version_req_number=`expr $postgresql_version_req_major \* 1000000 \
109
\+ $postgresql_version_req_minor \* 1000 \
110
\+ $postgresql_version_req_micro`
112
dnl Decompose version string of installed PostgreSQL
113
dnl and calculate its number representation
114
postgresql_version_major=`expr $POSTGRESQL_VERSION : '\([[0-9]]*\)'`
115
postgresql_version_minor=`expr $POSTGRESQL_VERSION : '[[0-9]]*\.\([[0-9]]*\)'`
116
postgresql_version_micro=`expr $POSTGRESQL_VERSION : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'`
117
if test "x$postgresql_version_micro" = "x"; then
118
postgresql_version_micro="0"
121
postgresql_version_number=`expr $postgresql_version_major \* 1000000 \
122
\+ $postgresql_version_minor \* 1000 \
123
\+ $postgresql_version_micro`
125
postgresql_version_check=`expr $postgresql_version_number \>\= $postgresql_version_req_number`
126
if test "$postgresql_version_check" = "1"; then
133
AC_SUBST([POSTGRESQL_VERSION])
134
AC_SUBST([POSTGRESQL_CFLAGS])
135
AC_SUBST([POSTGRESQL_LDFLAGS])