All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeremy Sowden <jeremy@azazel.net>
To: Netfilter Devel <netfilter-devel@vger.kernel.org>
Subject: [ulogd2 PATCH 05/10] build: use pkg-config for libpq if available
Date: Thu,  6 Jan 2022 21:09:32 +0000	[thread overview]
Message-ID: <20220106210937.1676554-6-jeremy@azazel.net> (raw)
In-Reply-To: <20220106210937.1676554-1-jeremy@azazel.net>

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@azazel.net>
---
 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@gmail.com>
-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


  parent reply	other threads:[~2022-01-06 21:10 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-06 21:09 [ulogd2 PATCH 00/10] Add pkg-config support Jeremy Sowden
2022-01-06 21:09 ` [ulogd2 PATCH 01/10] build: use `--enable-blah` flags for output plugins Jeremy Sowden
2022-01-06 21:09 ` [ulogd2 PATCH 02/10] build: use pkg-config for libdbi Jeremy Sowden
2022-01-06 21:09 ` [ulogd2 PATCH 03/10] build: use pkg-config or upstream M4 for mysql Jeremy Sowden
2022-01-06 22:15   ` Jan Engelhardt
2022-01-07  0:56     ` Duncan Roe
2022-01-08 17:05     ` Jeremy Sowden
2022-01-08 20:11       ` Jeremy Sowden
2022-01-06 21:09 ` [ulogd2 PATCH 04/10] build: use pkg-config or pcap-config for libpcap Jeremy Sowden
2022-01-06 21:09 ` Jeremy Sowden [this message]
2022-01-06 21:09 ` [ulogd2 PATCH 06/10] build: if `--enable-dbi` is `yes` abort if DBI is not found Jeremy Sowden
2022-01-06 21:09 ` [ulogd2 PATCH 07/10] build: if `--enable-mysql` is `yes` abort if MySQL " Jeremy Sowden
2022-01-06 21:09 ` [ulogd2 PATCH 08/10] build: if `--enable-pcap` is `yes` abort if libpcap " Jeremy Sowden
2022-01-06 21:09 ` [ulogd2 PATCH 09/10] build: if `--enable-pgsql` is `yes` abort if libpq " Jeremy Sowden
2022-01-06 21:09 ` [ulogd2 PATCH 10/10] build: if `--enable-sqlite3` is `yes` abort if libsqlite3 " Jeremy Sowden

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220106210937.1676554-6-jeremy@azazel.net \
    --to=jeremy@azazel.net \
    --cc=netfilter-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.