##### http://autoconf-archive.cryp.to/ax_lib_postgresql.html
#
# SYNOPSIS
#
# AX_LIB_POSTGRESQL([MINIMUM-VERSION])
#
# DESCRIPTION
#
# This macro provides tests of availability of PostgreSQL 'libpq'
# library of particular version or newer.
#
# AX_LIB_POSTGRESQL macro takes only one argument which is optional.
# If there is no required version passed, then macro does not run
# version test.
#
# The --with-postgresql option takes one of three possible values:
#
# no - do not check for PostgreSQL client library
#
# yes - do check for PostgreSQL library in standard locations
# (pg_config should be in the PATH)
#
# path - complete path to pg_config utility, use this option if
# pg_config can't be found in the PATH
#
# This macro calls:
#
# AC_SUBST(POSTGRESQL_CFLAGS)
# AC_SUBST(POSTGRESQL_LDFLAGS)
# AC_SUBST(POSTGRESQL_LIBS)
# AC_SUBST(POSTGRESQL_VERSION)
#
# And sets:
#
# HAVE_POSTGRESQL
#
# LAST MODIFICATION
#
# 2017-09-26 modified version detection to detect PostgreSQL 10 (Zabbix)
# 2006-07-16
#
# COPYLEFT
#
# Copyright (c) 2006 Mateusz Loskot <mateusz@loskot.net>
#
# Copying and distribution of this file, with or without
# modification, are permitted in any medium without royalty provided
# the copyright notice and this notice are preserved.
AC_DEFUN([AX_LIB_POSTGRESQL],
[
PG_CONFIG="no"
AC_ARG_WITH([postgresql],
AS_HELP_STRING([--with-postgresql@<:@=ARG@:>@],
[use PostgreSQL library @<:@default=no@:>@, optionally specify path to pg_config]
),
[
if test "x$withval" = "xno"; then
want_postgresql="no"
elif test "x$withval" = "xyes"; then
want_postgresql="yes"
else
want_postgresql="yes"
PG_CONFIG="$withval"
fi
],
[want_postgresql="no"]
)
POSTGRESQL_CFLAGS=""
POSTGRESQL_LDFLAGS=""
POSTGRESQL_LIBS=""
POSTGRESQL_VERSION=""
dnl
dnl Check PostgreSQL libraries (libpq)
dnl
if test "x$want_postgresql" = "xyes"; then
AC_PATH_PROG([PG_CONFIG], [pg_config], [])
if test -x "$PG_CONFIG"; then
POSTGRESQL_CFLAGS="`$PG_CONFIG --includedir`"
if test -n "$POSTGRESQL_CFLAGS"; then
POSTGRESQL_CFLAGS="-I$POSTGRESQL_CFLAGS";
fi
POSTGRESQL_LDFLAGS="`$PG_CONFIG --libdir`"
if test -n "$POSTGRESQL_LDFLAGS"; then
POSTGRESQL_LDFLAGS="-L$POSTGRESQL_LDFLAGS";
fi