Add pkg-config support
cover Add pkg-config support
A number of third-party libraries have added pkg-config support over the years. This patch-set updates configure to make use of it where it is available. It also fixes some conflicting option definitions and adds checks that cause configure to fail if a plugin has been explicitly requested, but the related third-party library is not available.
Patch 1: switch from --with-XXX to --enable-XXX for output
plugins.
Patches 2-5: use pkg-config for libdbi, libmysqlclient, libpcap and
libpq if available.
Patches 6-10: abort configure when an output plugin has been explicitly
enabled, but the related library is not available.
Changes since v1
* Better commit messages.
* Simpler mysql patch: remove the upstream m4 macro calls, and look for mysql_config the same way we do pg_config and pcap-config.
* AM_CPPFLAGS fixes for mysql, pcap, and postgresql.
* LIBADD fix for mysql.
Jeremy Sowden (10):
build: use --enable-XXX options for output plugins
build: use pkg-config for libdbi
build: use pkg-config or mysql_config for libmysqlclient
build: use pkg-config or pcap-config for libpcap
build: use pkg-config or pg_config for libpq
build: if --enable-dbi is yes, abort if libdbi is not found
build: if --enable-mysql is yes, abort if libmysqlclient is not
found
build: if --enable-pcap is yes, abort if libpcap is not found
build: if --enable-pgsql is yes, abort if libpq is not found
build: if --enable-sqlite3 is yes, abort if libsqlite3 is not
found
acinclude.m4 | 351 --------------------------------------- configure.ac | 192 +++++++++++++++++---- output/dbi/Makefile.am | 4 +- output/mysql/Makefile.am | 4 +- output/pcap/Makefile.am | 2 + output/pgsql/Makefile.am | 4 +- 6 files changed, 165 insertions(+), 392 deletions(-) delete mode 100644 acinclude.m4
Signature · 1 line
2.34.1
PATCH v2 1/10 build: use `--enable-XXX` options for output plugins
Currently, we use AC_ARG_WITH for output plugins. However, this is not consistent with the input plugins, which use AC_ARG_ENABLE, and in some cases (dbi, mysql, pgsql) the macro calls in configure.ac conflict with others in acinclude.m4. Use AC_ARG_ENABLE instead and change the name of the option for the JSON plugin from jansson to json.
--- configure.ac | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-)
configure.ac +20 -20
@@ -78,47 +78,47 @@ AS_IF([test "x$enable_nfacct" = "xyes"], [enable_nfacct=no]) AM_CONDITIONAL([BUILD_NFACCT], [test "x$enable_nfacct" = "xyes"]) -AC_ARG_WITH([pgsql], - [AS_HELP_STRING([--without-pgsql], [Build without postgresql output plugin [default=test]])]) -AS_IF([test "x$with_pgsql" != "xno"], +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"]) -AC_ARG_WITH([mysql], - [AS_HELP_STRING([--without-mysql], [Build without mysql output plugin [default=test]])]) -AS_IF([test "x$with_mysql" != "xno"], +AC_ARG_ENABLE([mysql], + [AS_HELP_STRING([--enable-mysql], [Enable MySQL output plugin [default=test]])]) +AS_IF([test "x$enable_mysql" != "xno"], [CT_CHECK_MYSQL_DB()]) AS_IF([test "x$MYSQL_LIB" != "x"], [enable_mysql=yes], [enable_mysql=no]) AM_CONDITIONAL([HAVE_MYSQL], [test "x$MYSQL_LIB" != "x"]) -AC_ARG_WITH([sqlite], - [AS_HELP_STRING([--without-sqlite], [Build without SQLITE3 output plugin [default=test]])]) -AS_IF([test "x$with_sqlite" != "xno"], +AC_ARG_ENABLE([sqlite3], + [AS_HELP_STRING([--enable-sqlite3], [Enable SQLITE3 output plugin [default=test]])]) +AS_IF([test "x$enable_sqlite3" != "xno"], [PKG_CHECK_MODULES([libsqlite3], [sqlite3], [], [:])]) AS_IF([test "x$libsqlite3_LIBS" != "x"], [enable_sqlite3=yes], [enable_sqlite3=no]) AM_CONDITIONAL([HAVE_SQLITE3], [test "x$libsqlite3_LIBS" != "x"]) -AC_ARG_WITH([dbi], - [AS_HELP_STRING([--without-dbi], [Build without DBI output plugin [default=test]])]) -AS_IF([test "x$with_dbi" != "xno"], +AC_ARG_ENABLE([dbi], + [AS_HELP_STRING([--enable-dbi], [Enable DBI output plugin [default=test]])]) +AS_IF([test "x$enable_dbi" != "xno"], [CT_CHECK_DBI()]) AS_IF([test "x$DBI_LIB" != "x"], [enable_dbi=yes], [enable_dbi=no]) AM_CONDITIONAL(HAVE_DBI, [test "x$DBI_LIB" != "x"]) -AC_ARG_WITH([pcap], - [AS_HELP_STRING([--without-pcap], [Build without PCAP output plugin [default=test]])]) -AS_IF([test "x$with_pcap" != "xno"], +AC_ARG_ENABLE([pcap], + [AS_HELP_STRING([--enable-pcap], [Enable PCAP output plugin [default=test]])]) +AS_IF([test "x$enable_pcap" != "xno"], [AC_SEARCH_LIBS([pcap_close], [pcap], [libpcap_LIBS="-lpcap"; LIBS=""]) AC_SUBST([libpcap_LIBS])]) AS_IF([test "x$libpcap_LIBS" != "x"], [enable_pcap=yes], [enable_pcap=no]) AM_CONDITIONAL([HAVE_PCAP], [test "x$libpcap_LIBS" != "x"]) -AC_ARG_WITH([jansson], - [AS_HELP_STRING([--without-jansson], [Build without JSON output plugin [default=test]])]) -AS_IF([test "x$with_jansson" != "xno"], +AC_ARG_ENABLE([json], + [AS_HELP_STRING([--enable-json], [Enable JSON output plugin [default=test]])]) +AS_IF([test "x$enable_json" != "xno"], [PKG_CHECK_MODULES([libjansson], [jansson], [], [:])]) -AS_IF([test "x$libjansson_LIBS" != "x"], [enable_jansson=yes], [enable_jansson=no]) +AS_IF([test "x$libjansson_LIBS" != "x"], [enable_json=yes], [enable_json=no]) AM_CONDITIONAL([HAVE_JANSSON], [test "x$libjansson_LIBS" != "x"]) AC_ARG_WITH([ulogd2libdir],
@@ -182,6 +182,6 @@ Ulogd configuration: MySQL plugin: ${enable_mysql} SQLITE3 plugin: ${enable_sqlite3} DBI plugin: ${enable_dbi} - JSON plugin: ${enable_jansson} + JSON plugin: ${enable_json} " echo "You can now run 'make' and 'make install'"
Signature · 1 line
2.34.1
PATCH v2 2/10 build: use pkg-config for libdbi
In reply to Jeremy Sowdenlibdbi introduced pkg-config support in 0.9.0, which was released in 2013. Use it.
--- acinclude.m4 | 84 ------------------------------------------ configure.ac | 6 +-- output/dbi/Makefile.am | 4 +- 3 files changed, 5 insertions(+), 89 deletions(-)
acinclude.m4 +0 -84
@@ -265,87 +265,3 @@ fi ]) -dnl @synopsis CT_CHECK_DBI -dnl -dnl This macro tries to find the headers and libraries for libdbi. -dnl -dnl If includes are found, the variable DBI_INC will be set. If -dnl libraries are found, the variable DBI_LIB will be set. if no check -dnl was successful, the script exits with a error message. -dnl -dnl @category InstalledPackages -dnl @author Pierre Chifflier <[email protected]> -dnl @version 2008-10-30 -dnl @license AllPermissive - -AC_DEFUN([CT_CHECK_DBI], [ - -AC_ARG_WITH(dbi, - [ --with-dbi=PREFIX Prefix of your libdbi installation], - [dbi=$withval], [dbi_prefix=]) -AC_ARG_WITH(dbi-inc, - [ --with-dbi-inc=PATH Path to the include directory of dbi], - [dbi_inc=$withval], [dbi_inc=/usr/include]) -AC_ARG_WITH(dbi-lib, - [ --with-dbi-lib=PATH Path to the libraries of dbi], - [dbi_lib=$withval], [dbi_lib=/usr/lib]) - - -AC_SUBST(DBI_INC) -AC_SUBST(DBI_LIB) - -if test "$dbi_prefix" != "no"; then - -if test "$dbi_prefix" != ""; then - AC_MSG_CHECKING([for libdbi includes in $dbi_prefix/include]) - if test -f "$dbi_prefix/include/dbi.h" ; then - DBI_INC="-I$dbi_prefix/include" - AC_MSG_RESULT([yes]) - elif test -f "$dbi_prefix/include/dbi/dbi.h" ; then - DBI_INC="-I$dbi_prefix/include/dbi" - AC_MSG_RESULT([yes]) - else - AC_MSG_WARN(dbi.h not found) - fi - AC_MSG_CHECKING([for libdbi in $dbi_prefix/lib]) - if test -f "$dbi_prefix/lib/libdbi.so" ; then - DBI_LIB="-L$dbi_prefix/lib -ldbi"; - AC_MSG_RESULT([yes]) - else - AC_MSG_WARN(libdbi.so not found) - fi -else - if test "$dbi_inc" != ""; then - AC_MSG_CHECKING([for libdbi includes in $dbi_inc]) - if test -f "$dbi_inc/dbi.h" ; then - DBI_INC="-I$dbi_inc" - AC_MSG_RESULT([yes]) - elif test -f "$dbi_inc/dbi/dbi.h" ; then - DBI_INC="-I$dbi_inc/dbi" - AC_MSG_RESULT([yes]) - else - AC_MSG_WARN(dbi.h not found) - fi - fi - if test "$dbi_lib" != ""; then - AC_MSG_CHECKING([for libdbi in $dbi_lib]) - if test -f "$dbi_lib/libdbi.so" ; then - DBI_LIB="-L$dbi_lib -ldbi"; - AC_MSG_RESULT([yes]) - else - AC_MSG_WARN(libdbi.so not found) - fi - fi -fi - -if test "$DBI_INC" = "" ; then - AC_CHECK_HEADER([dbi.h], [], AC_MSG_WARN(dbi.h not found)) -fi -if test "$DBI_LIB" = "" ; then - AC_CHECK_LIB(dbi, dbi_close, [], AC_MSG_WARN(libdbi.so not found)) -fi - -fi - -]) -
configure.ac +3 -3
@@ -102,9 +102,9 @@ AM_CONDITIONAL([HAVE_SQLITE3], [test "x$libsqlite3_LIBS" != "x"]) AC_ARG_ENABLE([dbi], [AS_HELP_STRING([--enable-dbi], [Enable DBI output plugin [default=test]])]) AS_IF([test "x$enable_dbi" != "xno"], - [CT_CHECK_DBI()]) -AS_IF([test "x$DBI_LIB" != "x"], [enable_dbi=yes], [enable_dbi=no]) -AM_CONDITIONAL(HAVE_DBI, [test "x$DBI_LIB" != "x"]) + [PKG_CHECK_MODULES([libdbi], [dbi], [], [:])]) +AS_IF([test "x$libdbi_LIBS" != "x"], [enable_dbi=yes], [enable_dbi=no]) +AM_CONDITIONAL([HAVE_DBI], [test "x$libdbi_LIBS" != "x"]) AC_ARG_ENABLE([pcap], [AS_HELP_STRING([--enable-pcap], [Enable PCAP output plugin [default=test]])])
output/dbi/Makefile.am +2 -2
@@ -1,9 +1,9 @@ include $(top_srcdir)/Make_global.am -AM_CPPFLAGS += $(DBI_INC) +AM_CPPFLAGS += $(libdbi_CFLAGS) pkglib_LTLIBRARIES = ulogd_output_DBI.la ulogd_output_DBI_la_SOURCES = ulogd_output_DBI.c ../../util/db.c -ulogd_output_DBI_la_LIBADD = ${DBI_LIB} +ulogd_output_DBI_la_LIBADD = $(libdbi_LIBS) ulogd_output_DBI_la_LDFLAGS = -avoid-version -module
Signature · 1 line
2.34.1
PATCH v2 3/10 build: use pkg-config or mysql_config for libmysqlclient
In reply to Jeremy SowdenRecent versions of mariadb and mysql support pkg-config. Older versions provide a mysql_config script. Use pkg-config if available, otherwise fall back to mysql_config.
--- acinclude.m4 | 93 ---------------------------------------- configure.ac | 53 +++++++++++++++++++++-- output/mysql/Makefile.am | 4 +- 3 files changed, 51 insertions(+), 99 deletions(-)
acinclude.m4 +0 -93
@@ -93,99 +93,6 @@ fi ]) -dnl @synopsis CT_CHECK_MYSQL_DB -dnl -dnl This macro tries to find the headers and librariess for the -dnl MySQL database to build client applications. -dnl -dnl If includes are found, the variable MYSQL_INC will be set. If -dnl libraries are found, the variable MYSQL_LIB will be set. if no check -dnl was successful, the script exits with a error message. -dnl -dnl @category InstalledPackages -dnl @author Harald Welte <[email protected]> -dnl @version 2006-01-07 -dnl @license AllPermissive - -AC_DEFUN([CT_CHECK_MYSQL_DB], [ - -AC_ARG_WITH(mysql, - [ --with-mysql=PREFIX Prefix of your MySQL installation], - [my_prefix=$withval], [my_prefix=]) -AC_ARG_WITH(mysql-inc, - [ --with-mysql-inc=PATH Path to the include directory of MySQL], - [my_inc=$withval], [my_inc=]) -AC_ARG_WITH(mysql-lib, - [ --with-mysql-lib=PATH Path to the libraries of MySQL], - [my_lib=$withval], [my_lib=]) - - -AC_SUBST(MYSQL_INC) -AC_SUBST(MYSQL_LIB) - -if test "$my_prefix" != "no"; then - -AC_MSG_CHECKING([for MySQL mysql_config program]) -for d in $my_prefix/bin /usr/bin /usr/local/bin /usr/local/mysql/bin /opt/mysql/bin /opt/packages/mysql/bin -do - if test -x $d/mysql_config -a "$cross_compiling" = "no"; - then - AC_MSG_RESULT(found mysql_config in $d) - MYSQL_INC=`$d/mysql_config --include` - MYSQL_LIB=`$d/mysql_config --libs` - break - fi -done - -if test "$MYSQL_INC" = ""; then - if test "$my_prefix" != ""; then - AC_MSG_CHECKING([for MySQL includes in $my_prefix/include]) - if test -f "$my_prefix/include/mysql.h" ; then - MYSQL_INC="-I$my_prefix/include" - AC_MSG_RESULT([yes]) - else - AC_MSG_WARN(mysql.h not found) - fi - AC_MSG_CHECKING([for MySQL libraries in $my_prefix/lib]) - if test -f "$my_prefix/lib/libmysql.so" ; then - MYSQL_LIB="-L$my_prefix/lib -lmysqlclient" - AC_MSG_RESULT([yes]) - else - AC_MSG_WARN(libmysqlclient.so not found) - fi - else - if test "$my_inc" != ""; then - AC_MSG_CHECKING([for MySQL includes in $my_inc]) - if test -f "$my_inc/mysql.h" ; then - MYSQL_INC="-I$my_inc" - AC_MSG_RESULT([yes]) - else - AC_MSG_WARN(mysql.h not found) - fi - fi - if test "$my_lib" != ""; then - AC_MSG_CHECKING([for MySQL libraries in $my_lib]) - if test -f "$my_lib/libmysqlclient.so" ; then - MYSQL_LIB="-L$my_lib -lmysqlclient" - AC_MSG_RESULT([yes]) - else - AC_MSG_WARN(libmysqlclient.so not found) - fi - fi - fi -fi - -if test "$MYSQL_INC" = "" ; then - AC_CHECK_HEADER([mysql.h], [], AC_MSG_WARN(mysql.h not found)) -fi -if test "$MYSQL_LIB" = "" ; then - AC_CHECK_LIB(mysqlclient, mysql_close, [], AC_MSG_WARN(libmysqlclient.so not found)) -fi - -fi - -]) - dnl @synopsis CT_CHECK_PCAP dnl dnl This macro tries to find the headers and libraries for libpcap.
configure.ac +49 -4
59 lines not on this page · raw message
output/mysql/Makefile.am +2 -2
@@ -1,9 +1,9 @@ include $(top_srcdir)/Make_global.am -AM_CPPFLAGS += $(MYSQL_INC) +AM_CPPFLAGS += $(libmysqlclient_CFLAGS) pkglib_LTLIBRARIES = ulogd_output_MYSQL.la ulogd_output_MYSQL_la_SOURCES = ulogd_output_MYSQL.c ../../util/db.c -ulogd_output_MYSQL_la_LIBADD = ${MYSQL_LIB} +ulogd_output_MYSQL_la_LIBADD = $(libmysqlclient_LIBS) ulogd_output_MYSQL_la_LDFLAGS = -avoid-version -module
Signature · 1 line
2.34.1
PATCH v2 4/10 build: use pkg-config or pcap-config for libpcap
In reply to Jeremy SowdenRecent versions of libpcap support pkg-config. Older versions provide a pcap-config script. Use pkg-config if available, otherwise fall back to pcap-config.
--- acinclude.m4 | 79 ----------------------------------------- configure.ac | 30 ++++++++++++++-- output/pcap/Makefile.am | 2 ++ 3 files changed, 29 insertions(+), 82 deletions(-)
acinclude.m4 +0 -79
@@ -93,82 +93,3 @@ fi ]) -dnl @synopsis CT_CHECK_PCAP -dnl -dnl This macro tries to find the headers and libraries for libpcap. -dnl -dnl If includes are found, the variable PCAP_INC will be set. If -dnl libraries are found, the variable PCAP_LIB will be set. if no check -dnl was successful, the script exits with a error message. -dnl -dnl @category InstalledPackages -dnl @author Harald Welte <[email protected]> -dnl @version 2006-01-07 -dnl @license AllPermissive - -AC_DEFUN([CT_CHECK_PCAP], [ - -AC_ARG_WITH(pcap, - [ --with-pcap=PREFIX Prefix of your libpcap installation], - [pcap_prefix=$withval], [pcap_prefix=]) -AC_ARG_WITH(pcap-inc, - [ --with-pcap-inc=PATH Path to the include directory of pcap], - [pcap_inc=$withval], [pcap_inc=/usr/include]) -AC_ARG_WITH(pcap-lib, - [ --with-pcap-lib=PATH Path to the libraries of pcap], - [pcap_lib=$withval], [pcap_lib=/usr/lib]) - - -AC_SUBST(PCAP_INC) -AC_SUBST(PCAP_LIB) -AC_SUBST(HAVE_PCAP_LIB) - -if test "$pcap_prefix" != "no"; then - -if test "$pcap_prefix" != ""; then - AC_MSG_CHECKING([for libpcap includes in $pcap_prefix/include]) - if test -f "$pcap_prefix/include/pcap.h" ; then - PCAP_INC="-I$pcap_prefix/include" - AC_MSG_RESULT([yes]) - else - AC_MSG_WARN(pcap.h not found) - fi - AC_MSG_CHECKING([for libpcap in $pcap_prefix/lib]) - if test -f "$pcap_prefix/lib/libpcap.so" ; then - PCAP_LIB="-L$pcap_prefix/lib -lpcap"; - AC_MSG_RESULT([yes]) - else - AC_MSG_WARN(libpcap.so not found) - fi -else - if test "$pcap_inc" != ""; then - AC_MSG_CHECKING([for libpcap includes in $pcap_inc]) - if test -f "$pcap_inc/pcap.h" ; then - PCAP_INC="-I$pcap_inc" - AC_MSG_RESULT([yes]) - else - AC_MSG_WARN(pcap.h not found) - fi - fi - if test "$pcap_lib" != ""; then - AC_MSG_CHECKING([for libpcap in $pcap_lib]) - if test -f "$pcap_lib/libpcap.so" ; then - PCAP_LIB="-L$pcap_lib -lpcap"; - AC_MSG_RESULT([yes]) - else - AC_MSG_WARN(libpcap.so not found) - fi - fi -fi - -if test "$PCAP_INC" = "" ; then - AC_CHECK_HEADER([pcap.h], [], AC_MSG_WARN(pcap.h not found)) -fi -if test "$PCAP_LIB" = "" ; then - AC_CHECK_LIB(pcap, pcap_close, [HAVE_PCAP_LIB="yes"], AC_MSG_WARN(libpcap.so not found)) -fi - -fi - -]) -
configure.ac +27 -3
@@ -153,9 +153,33 @@ AM_CONDITIONAL([HAVE_DBI], [test "x$libdbi_LIBS" != "x"]) AC_ARG_ENABLE([pcap], [AS_HELP_STRING([--enable-pcap], [Enable PCAP output plugin [default=test]])]) -AS_IF([test "x$enable_pcap" != "xno"], - [AC_SEARCH_LIBS([pcap_close], [pcap], [libpcap_LIBS="-lpcap"; LIBS=""]) - AC_SUBST([libpcap_LIBS])]) +AS_IF([test "x$enable_pcap" != "xno"], [ + + PKG_CHECK_EXISTS([libpcap], [PKG_CHECK_MODULES([libpcap], [libpcap])], [ + + AC_ARG_WITH([pcap-config], + [AS_HELP_STRING([--with-pcap-config=PATH], [Path to the pcap-config script])], + [pcap_config="$withval"], [pcap_config=pcap-config]) + + AC_MSG_CHECKING([for pcap-config]) + + AS_IF([command -v "$pcap_config" >/dev/null], [ + + libpcap_CFLAGS="`$pcap_config --cflags`" + libpcap_LIBS="`$pcap_config --libs`" + + AC_SUBST([libpcap_CFLAGS]) + AC_SUBST([libpcap_LIBS]) + + AC_MSG_RESULT([$pcap_config]) + + ], [ + AC_MSG_RESULT([no]) + ]) + + ]) + +]) AS_IF([test "x$libpcap_LIBS" != "x"], [enable_pcap=yes], [enable_pcap=no]) AM_CONDITIONAL([HAVE_PCAP], [test "x$libpcap_LIBS" != "x"])
output/pcap/Makefile.am +2 -0
@@ -1,5 +1,7 @@ include $(top_srcdir)/Make_global.am +AM_CPPFLAGS += $(libpcap_CFLAGS) + pkglib_LTLIBRARIES = ulogd_output_PCAP.la ulogd_output_PCAP_la_SOURCES = ulogd_output_PCAP.c
Signature · 1 line
2.34.1
PATCH v2 5/10 build: use pkg-config or pg_config for libpq
In reply to Jeremy SowdenRecent versions of postgresql support pkg-config. Use pkg-config if available, otherwise fall back to pg_config.
--- acinclude.m4 | 95 ---------------------------------------- configure.ac | 33 ++++++++++++-- output/pgsql/Makefile.am | 4 +- 3 files changed, 31 insertions(+), 101 deletions(-) delete mode 100644 acinclude.m4
acinclude.m4 deleted +0 -95
@@ -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 <[email protected]> -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 - -]) -
configure.ac +29 -4
@@ -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]])])
output/pgsql/Makefile.am +2 -2
@@ -1,9 +1,9 @@ include $(top_srcdir)/Make_global.am -AM_CPPFLAGS += -I$(PQINCPATH) +AM_CPPFLAGS += $(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
Signature · 1 line
2.34.1
PATCH v2 6/10 build: if `--enable-dbi` is `yes`, abort if libdbi is not found
In reply to Jeremy SowdenIf DBI support has been explicitly requested, abort if it is not available.
--- configure.ac | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
configure.ac +7 -2
@@ -171,8 +171,13 @@ AM_CONDITIONAL([HAVE_SQLITE3], [test "x$libsqlite3_LIBS" != "x"]) AC_ARG_ENABLE([dbi], [AS_HELP_STRING([--enable-dbi], [Enable DBI output plugin [default=test]])]) -AS_IF([test "x$enable_dbi" != "xno"], - [PKG_CHECK_MODULES([libdbi], [dbi], [], [:])]) +AS_IF([test "x$enable_dbi" != "xno"], [ + PKG_CHECK_MODULES([libdbi], [dbi], [], [ + AS_IF([test "x$enable_dbi" = "xyes"], [ + AC_MSG_ERROR([$libdbi_PKG_ERRORS]) + ]) + ]) +]) AS_IF([test "x$libdbi_LIBS" != "x"], [enable_dbi=yes], [enable_dbi=no]) AM_CONDITIONAL([HAVE_DBI], [test "x$libdbi_LIBS" != "x"])
Signature · 1 line
2.34.1
PATCH v2 7/10 build: if `--enable-mysql` is `yes`, abort if libmysqlclient is not found
In reply to Jeremy SowdenIf MySQL support has been explicitly requested, abort if it is not available.
--- configure.ac | 6 ++++++ 1 file changed, 6 insertions(+)
configure.ac +6 -0
@@ -156,6 +156,12 @@ AS_IF([test "x$enable_mysql" != "xno"], [ AC_MSG_RESULT([no]) ]) + AS_IF([test "x$libmysqlclient_LIBS" = "x"], [ + AS_IF([test "x$enable_mysql" = "xyes"], [ + AC_MSG_ERROR([libmysqlclient not found]) + ]) + ]) + ]) ])
Signature · 1 line
2.34.1
PATCH v2 8/10 build: if `--enable-pcap` is `yes`, abort if libpcap is not found
In reply to Jeremy SowdenIf libpcap support has been explicitly requested, abort if it is not available.
--- configure.ac | 6 ++++++ 1 file changed, 6 insertions(+)
configure.ac +6 -0
@@ -213,6 +213,12 @@ AS_IF([test "x$enable_pcap" != "xno"], [ AC_MSG_RESULT([no]) ]) + AS_IF([test "x$libpcap_LIBS" = "x"], [ + AS_IF([test "x$enable_pcap" = "xyes"], [ + AC_MSG_ERROR([libpcap not found]) + ]) + ]) + ]) ])
Signature · 1 line
2.34.1
PATCH v2 9/10 build: if `--enable-pgsql` is `yes`, abort if libpq is not found
In reply to Jeremy SowdenIf PostgreSQL support has been explicitly requested, abort if it is not available.
--- configure.ac | 6 ++++++ 1 file changed, 6 insertions(+)
configure.ac +6 -0
@@ -104,6 +104,12 @@ AS_IF([test "x$enable_pgsql" != "xno"], [ AC_MSG_RESULT([no]) ]) + AS_IF([test "x$libpq_LIBS" = "x"], [ + AS_IF([test "x$enable_pgsql" = "xyes"], [ + AC_MSG_ERROR([libpq not found]) + ]) + ]) + ]) ])
Signature · 1 line
2.34.1
PATCH v2 10/10 build: if `--enable-sqlite3` is `yes`, abort if libsqlite3 is not found
In reply to Jeremy SowdenIf SQLITE3 support has been explicitly requested, abort if it is not available.
--- configure.ac | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
configure.ac +7 -2
@@ -176,8 +176,13 @@ AM_CONDITIONAL([HAVE_MYSQL], [test "x$libmysqlclient_LIBS" != "x"]) AC_ARG_ENABLE([sqlite3], [AS_HELP_STRING([--enable-sqlite3], [Enable SQLITE3 output plugin [default=test]])]) -AS_IF([test "x$enable_sqlite3" != "xno"], - [PKG_CHECK_MODULES([libsqlite3], [sqlite3], [], [:])]) +AS_IF([test "x$enable_sqlite3" != "xno"], [ + PKG_CHECK_MODULES([libsqlite3], [sqlite3], [], [ + AS_IF([test "x$enable_sqlite3" = "xyes"], [ + AC_MSG_ERROR([$libsqlite3_PKG_ERRORS]) + ]) + ]) +]) AS_IF([test "x$libsqlite3_LIBS" != "x"], [enable_sqlite3=yes], [enable_sqlite3=no]) AM_CONDITIONAL([HAVE_SQLITE3], [test "x$libsqlite3_LIBS" != "x"])
Signature · 1 line
2.34.1
Pablo Neira Ayuso
maintainerQuoted 15 lines · Jeremy Sowden
A number of third-party libraries have added pkg-config support over the years. This patch-set updates configure to make use of it where it is available. It also fixes some conflicting option definitions and adds checks that cause configure to fail if a plugin has been explicitly requested, but the related third-party library is not available.
Patch 1: switch from
--with-XXXto--enable-XXXfor output
plugins.
Patches 2-5: use pkg-config for libdbi, libmysqlclient, libpcap and
libpq if available.
Patches 6-10: abort configure when an output plugin has been explicitly
enabled, but the related library is not available.Changes since v1
Quoted 8 lines
* Better commit messages.
* Simpler mysql patch: remove the upstream m4 macro calls, and look formysql_configthe same way we dopg_configandpcap-config.
*AM_CPPFLAGSfixes for mysql, pcap, and postgresql.
*LIBADDfix for mysql.Jeremy Sowden (10):
build: use--enable-XXXoptions for output plugins
I hesitate about this change from --with-XYZ to --enable-XYZ, it will force package maintainers to update their scripts.
Althought I agree after reading the documentation that --enable-XYZ might make more sense since the input plugins rely on netfilter libraries which are supposed to be "external software".
Quoted 24 lines
build: use pkg-config for libdbi
build: use pkg-config ormysql_configfor libmysqlclient
build: use pkg-config or pcap-config for libpcap
build: use pkg-config orpg_configfor libpq
build: if--enable-dbiisyes, abort if libdbi is not found
build: if--enable-mysqlisyes, abort if libmysqlclient is not
found
build: if--enable-pcapisyes, abort if libpcap is not found
build: if--enable-pgsqlisyes, abort if libpq is not found
build: if--enable-sqlite3isyes, abort if libsqlite3 is not
foundacinclude.m4 | 351 --------------------------------------- configure.ac | 192 +++++++++++++++++---- output/dbi/Makefile.am | 4 +- output/mysql/Makefile.am | 4 +- output/pcap/Makefile.am | 2 + output/pgsql/Makefile.am | 4 +- 6 files changed, 165 insertions(+), 392 deletions(-) delete mode 100644 acinclude.m4Signature · 1 line
2.34.1
Quoted 25 lines · Pablo Neira Ayuso
Quoted 24 lines · Jeremy Sowden
A number of third-party libraries have added pkg-config support over the years. This patch-set updates configure to make use of it where it is available. It also fixes some conflicting option definitions and adds checks that cause configure to fail if a plugin has been explicitly requested, but the related third-party library is not available.
Patch 1: switch from
--with-XXXto--enable-XXXfor output
plugins.
Patches 2-5: use pkg-config for libdbi, libmysqlclient, libpcap and
libpq if available.
Patches 6-10: abort configure when an output plugin has been
explicitly enabled, but the related library is not available.Changes since v1
* Better commit messages.
* Simpler mysql patch: remove the upstream m4 macro calls, and look formysql_configthe same way we dopg_configandpcap-config. *AM_CPPFLAGSfixes for mysql, pcap, and postgresql.
*LIBADDfix for mysql.
Quoted 5 lines
Quoted 2 lines
Jeremy Sowden (10):
build: use--enable-XXXoptions for output pluginsI hesitate about this change from --with-XYZ to --enable-XYZ, it will force package maintainers to update their scripts.
True. However, it is a one-off change, and ulogd2 doesn't change often -- the last release was in 2018 -- so I would argue that the maintenance burden isn't very great.
Quoted 29 lines
Althought I agree after reading the documentation that --enable-XYZ might make more sense since the input plugins rely on netfilter libraries which are supposed to be "external software".
Quoted 24 lines
build: use pkg-config for libdbi
build: use pkg-config ormysql_configfor libmysqlclient
build: use pkg-config or pcap-config for libpcap
build: use pkg-config orpg_configfor libpq
build: if--enable-dbiisyes, abort if libdbi is not found
build: if--enable-mysqlisyes, abort if libmysqlclient is
not found
build: if--enable-pcapisyes, abort if libpcap is not found
build: if--enable-pgsqlisyes, abort if libpq is not found
build: if--enable-sqlite3isyes, abort if libsqlite3 is not
foundacinclude.m4 | 351 --------------------------------------- configure.ac | 192 +++++++++++++++++---- output/dbi/Makefile.am | 4 +- output/mysql/Makefile.am | 4 +- output/pcap/Makefile.am | 2 + output/pgsql/Makefile.am | 4 +- 6 files changed, 165 insertions(+), 392 deletions(-) delete mode 100644 acinclude.m4--
2.34.1
Quoted 29 lines · Jeremy Sowden
Quoted 28 lines · Pablo Neira Ayuso
Quoted 26 lines · Jeremy Sowden
A number of third-party libraries have added pkg-config support over the years. This patch-set updates configure to make use of it where it is available. It also fixes some conflicting option definitions and adds checks that cause configure to fail if a plugin has been explicitly requested, but the related third-party library is not available.
Patch 1: switch from
--with-XXXto--enable-XXXfor output
plugins.
Patches 2-5: use pkg-config for libdbi, libmysqlclient, libpcap and
libpq if available.
Patches 6-10: abort configure when an output plugin has been
explicitly enabled, but the related library is not available.Changes since v1
* Better commit messages.
* Simpler mysql patch: remove the upstream m4 macro calls, and look formysql_configthe same way we dopg_configandpcap-config. *AM_CPPFLAGSfixes for mysql, pcap, and postgresql.
*LIBADDfix for mysql.Jeremy Sowden (10):
build: use--enable-XXXoptions for output plugins
Quoted 6 lines
Quoted 2 lines
I hesitate about this change from --with-XYZ to --enable-XYZ, it will force package maintainers to update their scripts.
True. However, it is a one-off change, and ulogd2 doesn't change often -- the last release was in 2018 -- so I would argue that the maintenance burden isn't very great.
Right. The input plugins also are enabled by default if the netfilter library dependencies are present.
Applied, thanks for explaining.