Recent versions of postgresql have supported pkg-config. Use pkg-config if available, otherwise fall back to pg_config. Signed-off-by: Jeremy Sowden <jeremy@xxxxxxxxxx> --- acinclude.m4 | 95 ---------------------------------------- configure.ac | 33 ++++++++++++-- output/pgsql/Makefile.am | 4 +- 3 files changed, 31 insertions(+), 101 deletions(-) delete mode 100644 acinclude.m4 diff --git a/acinclude.m4 b/acinclude.m4 deleted file mode 100644 index 6d88c3a53cff..000000000000 --- a/acinclude.m4 +++ /dev/null @@ -1,95 +0,0 @@ -dnl @synopsis CT_CHECK_POSTGRES_DB -dnl -dnl This macro tries to find the headers and libraries for the -dnl PostgreSQL database to build client applications. -dnl -dnl If includes are found, the variable PQINCPATH will be set. If -dnl libraries are found, the variable PQLIBPATH will be set. if no check -dnl was successful, the script exits with a error message. -dnl -dnl @category InstalledPackages -dnl @author Christian Toepp <c.toepp@xxxxxxxxx> -dnl @version 2005-12-30 -dnl @license AllPermissive - -AC_DEFUN([CT_CHECK_POSTGRES_DB], [ - -AC_ARG_WITH(pgsql, - [ --with-pgsql=PREFIX Prefix of your PostgreSQL installation], - [pg_prefix=$withval], [pg_prefix=]) -AC_ARG_WITH(pgsql-inc, - [ --with-pgsql-inc=PATH Path to the include directory of PostgreSQL], - [pg_inc=$withval], [pg_inc=]) -AC_ARG_WITH(pgsql-lib, - [ --with-pgsql-lib=PATH Path to the libraries of PostgreSQL], - [pg_lib=$withval], [pg_lib=]) - - -AC_SUBST(PQINCPATH) -AC_SUBST(PQLIBPATH) -AC_SUBST(PQLIBS) -PQLIBS=-lpq - -if test "$pg_prefix" != "no"; then - -AC_MSG_CHECKING([for PostgreSQL pg_config program]) -for d in $pg_prefix/bin /usr/bin /usr/local/bin /usr/local/pgsql/bin /opt/pgsql/bin /opt/packages/pgsql/bin -do - if test -x $d/pg_config -a "$cross_compiling" = "no"; - then - AC_MSG_RESULT(found pg_config in $d) - PQINCPATH=`$d/pg_config --includedir` - PQLIBPATH=`$d/pg_config --libdir` - break - fi -done - -if test "$PQINCPATH" = ""; then - if test "$pg_prefix" != ""; then - AC_MSG_CHECKING([for PostgreSQL includes in $pg_prefix/include]) - if test -f "$pg_prefix/include/libpq-fe.h" ; then - PQINCPATH="-I$pg_prefix/include" - AC_MSG_RESULT([yes]) - else - AC_MSG_WARN(libpq-fe.h not found) - fi - AC_MSG_CHECKING([for PostgreSQL libraries in $pg_prefix/lib]) - if test -f "$pg_prefix/lib/libpq.so" ; then - PQLIBPATH="-L$pg_prefix/lib" - AC_MSG_RESULT([yes]) - else - AC_MSG_WARN(libpq.so not found) - fi - else - if test "$pg_inc" != ""; then - AC_MSG_CHECKING([for PostgreSQL includes in $pg_inc]) - if test -f "$pg_inc/libpq-fe.h" ; then - PQINCPATH="-I$pg_inc" - AC_MSG_RESULT([yes]) - else - AC_MSG_WARN(libpq-fe.h not found) - fi - fi - if test "$pg_lib" != ""; then - AC_MSG_CHECKING([for PostgreSQL libraries in $pg_lib]) - if test -f "$pg_lib/libpq.so" ; then - PQLIBPATH="-L$pg_lib" - AC_MSG_RESULT([yes]) - else - AC_MSG_WARN(libpq.so not found) - fi - fi - fi -fi - -if test "$PQINCPATH" = "" ; then - AC_CHECK_HEADER([libpq-fe.h], [], AC_MSG_WARN(libpq-fe.h not found)) -fi -if test "$PQLIBPATH" = "" ; then - AC_CHECK_LIB(pq, PQconnectdb, [], AC_MSG_WARN(libpq.so not found)) -fi - -fi - -]) - diff --git a/configure.ac b/configure.ac index bbca53e4c394..df6fa543e81f 100644 --- a/configure.ac +++ b/configure.ac @@ -80,10 +80,35 @@ AM_CONDITIONAL([BUILD_NFACCT], [test "x$enable_nfacct" = "xyes"]) AC_ARG_ENABLE([pgsql], [AS_HELP_STRING([--enable-pgsql], [Enable PostgreSQL output plugin [default=test]])]) -AS_IF([test "x$enable_pgsql" != "xno"], - [CT_CHECK_POSTGRES_DB()]) -AS_IF([test "x$PQLIBPATH" != "x"], [enable_pgsql=yes], [enable_pgsql=no]) -AM_CONDITIONAL([HAVE_PGSQL], [test "x$PQLIBPATH" != "x"]) +AS_IF([test "x$enable_pgsql" != "xno"], [ + + PKG_CHECK_EXISTS([libpq], [PKG_CHECK_MODULES([libpq], [libpq])], [ + + AC_ARG_WITH([pg_config], + [AS_HELP_STRING([--with-pg-config=PATH], [Path to the pg_config script])], + [pg_config="$withval"], [pg_config=pg_config]) + + AC_MSG_CHECKING([for pg_config]) + + AS_IF([command -v "$pg_config" >/dev/null], [ + + libpq_CFLAGS="`$pg_config --includedir`" + libpq_LIBS="`$pg_config --libdir` -lpq" + + AC_SUBST([libpq_CFLAGS]) + AC_SUBST([libpq_LIBS]) + + AC_MSG_RESULT([$pg_config]) + + ], [ + AC_MSG_RESULT([no]) + ]) + + ]) + +]) +AS_IF([test "x$libpq_LIBS" != "x"], [enable_pgsql=yes], [enable_pgsql=no]) +AM_CONDITIONAL([HAVE_PGSQL], [test "x$libpq_LIBS" != "x"]) AC_ARG_ENABLE([mysql], [AS_HELP_STRING([--enable-mysql], [Enable MySQL output plugin [default=test]])]) diff --git a/output/pgsql/Makefile.am b/output/pgsql/Makefile.am index 9cdf22d7f765..c458c04900ba 100644 --- a/output/pgsql/Makefile.am +++ b/output/pgsql/Makefile.am @@ -1,9 +1,9 @@ include $(top_srcdir)/Make_global.am -AM_CPPFLAGS += -I$(PQINCPATH) +AM_CPPFLAGS += -I$(libpq_CFLAGS) pkglib_LTLIBRARIES = ulogd_output_PGSQL.la ulogd_output_PGSQL_la_SOURCES = ulogd_output_PGSQL.c ../../util/db.c -ulogd_output_PGSQL_la_LIBADD = ${PQLIBS} +ulogd_output_PGSQL_la_LIBADD = $(libpq_LIBS) ulogd_output_PGSQL_la_LDFLAGS = -avoid-version -module -- 2.34.1