3 # AX_LIB_POSTGRESQL_SVR([MINIMUM-VERSION])
7 # This macro provides tests of availability of PostgreSQL server library
11 # AC_SUBST(POSTGRESQL_PGXS)
12 # AC_SUBST(POSTGRESQL_SERVER_CFLAGS)
16 # Copyright (c) 2008 Mateusz Loskot <mateusz@loskot.net>
17 # Copyright (c) 2015 Sarah Hoffmann <lonia@denofr.de>
19 # Copying and distribution of this file, with or without modification, are
20 # permitted in any medium without royalty provided the copyright notice
21 # and this notice are preserved.
23 AC_DEFUN([AX_LIB_POSTGRESQL_SVR],
25 AC_ARG_WITH([postgresql],
26 AC_HELP_STRING([--with-postgresql-svr=@<:@ARG@:>@],
27 [use PostgreSQL server library @<:@default=yes@:>@, optionally specify path to pg_config]
30 if test "$withval" = "no"; then
32 elif test "$withval" = "yes"; then
39 [want_postgresql="yes"]
43 dnl Check PostgreSQL server libraries
46 if test "$want_postgresql" = "yes"; then
48 if test -z "$PG_CONFIG" -o test; then
49 AC_PATH_PROG([PG_CONFIG], [pg_config], [])
52 if test ! -x "$PG_CONFIG"; then
53 AC_MSG_ERROR([$PG_CONFIG does not exist or it is not an exectuable file])
58 if test "$PG_CONFIG" != "no"; then
59 AC_MSG_CHECKING([for PostgreSQL server libraries])
61 POSTGRESQL_SERVER_CFLAGS="-I`$PG_CONFIG --includedir-server`"
63 POSTGRESQL_VERSION=`$PG_CONFIG --version | sed -e 's#PostgreSQL ##'`
65 POSTGRESQL_PGXS=`$PG_CONFIG --pgxs`
66 if test -f "$POSTGRESQL_PGXS"
68 found_postgresql="yes"
78 dnl Check if required version of PostgreSQL is available
82 postgresql_version_req=ifelse([$1], [], [], [$1])
84 if test "$found_postgresql" = "yes" -a -n "$postgresql_version_req"; then
86 AC_MSG_CHECKING([if PostgreSQL version is >= $postgresql_version_req])
88 dnl Decompose required version string of PostgreSQL
89 dnl and calculate its number representation
90 postgresql_version_req_major=`expr $postgresql_version_req : '\([[0-9]]*\)'`
91 postgresql_version_req_minor=`expr $postgresql_version_req : '[[0-9]]*\.\([[0-9]]*\)'`
92 postgresql_version_req_micro=`expr $postgresql_version_req : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'`
93 if test "x$postgresql_version_req_micro" = "x"; then
94 postgresql_version_req_micro="0"
97 postgresql_version_req_number=`expr $postgresql_version_req_major \* 1000000 \
98 \+ $postgresql_version_req_minor \* 1000 \
99 \+ $postgresql_version_req_micro`
101 dnl Decompose version string of installed PostgreSQL
102 dnl and calculate its number representation
103 postgresql_version_major=`expr $POSTGRESQL_VERSION : '\([[0-9]]*\)'`
104 postgresql_version_minor=`expr $POSTGRESQL_VERSION : '[[0-9]]*\.\([[0-9]]*\)'`
105 postgresql_version_micro=`expr $POSTGRESQL_VERSION : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'`
106 if test "x$postgresql_version_micro" = "x"; then
107 postgresql_version_micro="0"
110 postgresql_version_number=`expr $postgresql_version_major \* 1000000 \
111 \+ $postgresql_version_minor \* 1000 \
112 \+ $postgresql_version_micro`
114 postgresql_version_check=`expr $postgresql_version_number \>\= $postgresql_version_req_number`
115 if test "$postgresql_version_check" = "1"; then
122 AC_SUBST([POSTGRESQL_PGXS])
123 AC_SUBST([POSTGRESQL_SERVER_CFLAGS])