Source: ulogd2
Version: 2.0.7-1
Tags: patch upstream
User: [email protected]
Usertags: rebootstrap
ulogd2 fails to cross build from source, because it fails to detect
client libraries for postgres and mysql. The relevant code prefers
pg_config and mysql_config, but explicity opts out of these for cross
compilation (even though using them would actually work). Opting out is
good for other distributions as these utilities typically produce
results for a different architecture.
The fallback code seems completely unmaintained and doesn't work at all.
For instance, PQINCPATH (see acinclude.m4) is sometimes initialized to a
directory by pg_config, but receives full flags in the later fallback
code resulting in -I-I/somedir due to output/pgsql/Makefile.am adding
another -I.
A good way to discover these libraries is pkg-config. Unfortunately, we
cannot use PKG_CHECK_MODULES in a shell if, because PKG_CHECK_MODULES
uses AC_REQUIRE. Therefore the shell if must be converted to AS_IF.
Then we can proceed using PKG_CHECK_MODULES, though note that
mysqlclient.pc is not presently discoverable (#878340), so we need to
consider mariadb.pc as well.
That sounds a lot of complexity, but once we switch over to pkg-config,
the cross stuff just works. I've implemented it to gracefully fall back
to the old way (mysql_config/pg_config).
Please consider applying the attached patch as it makes ulogd2 cross
buildable.
Helmut
--- ulogd2-2.0.7.orig/acinclude.m4
+++ ulogd2-2.0.7/acinclude.m4
@@ -30,7 +30,12 @@
AC_SUBST(PQLIBS)
PQLIBS=-lpq
-if test "$pg_prefix" != "no"; then
+AS_IF([test "$pg_prefix" != "no"],[
+
+PKG_CHECK_MODULES([LIBPQ],[libpq],[
+ PQINCPATH=$LIBPQ_CFLAGS
+ PQLIBPATH=$LIBPQ_LIBS
+],[
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
@@ -38,7 +43,7 @@
if test -x $d/pg_config -a "$cross_compiling" = "no";
then
AC_MSG_RESULT(found pg_config in $d)
- PQINCPATH=`$d/pg_config --includedir`
+ PQINCPATH=-I`$d/pg_config --includedir`
PQLIBPATH=`$d/pg_config --libdir`
break
fi
@@ -89,9 +94,7 @@
AC_CHECK_LIB(pq, PQconnectdb, [], AC_MSG_WARN(libpq.so not found))
fi
-fi
-
-])
+])])])
dnl @synopsis CT_CHECK_MYSQL_DB
dnl
@@ -123,7 +126,15 @@
AC_SUBST(MYSQL_INC)
AC_SUBST(MYSQL_LIB)
-if test "$my_prefix" != "no"; then
+AS_IF([test "$my_prefix" != no],[
+PKG_CHECK_MODULES([MYSQLCLIENT],[mysqlclient],[
+ MYSQL_INC=$MYSQLCLIENT_CFLAGS
+ MYSQL_LIB=$MYSQLCLIENT_LIBS
+],[
+PKG_CHECK_MODULES([MYSQLCLIENT],[mariadb],[
+ MYSQL_INC=$MYSQLCLIENT_CFLAGS
+ MYSQL_LIB=$MYSQLCLIENT_LIBS
+],[
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
@@ -182,9 +193,7 @@
AC_CHECK_LIB(mysqlclient, mysql_close, [], AC_MSG_WARN(libmysqlclient.so not found))
fi
-fi
-
-])
+])])])])
dnl @synopsis CT_CHECK_PCAP
dnl
--- ulogd2-2.0.7.orig/output/pgsql/Makefile.am
+++ ulogd2-2.0.7/output/pgsql/Makefile.am
@@ -1,5 +1,5 @@
-AM_CPPFLAGS = -I$(top_srcdir)/include -I$(PQINCPATH)
+AM_CPPFLAGS = -I$(top_srcdir)/include $(PQINCPATH)
AM_CFLAGS = ${regular_CFLAGS}
if HAVE_PGSQL