Source: pure-ftpd
Version: 1.0.49-4.1
Tags: patch upstream
User: debian-cr...@lists.debian.org
Usertags: ftcbfs

pure-ftpd fails to cross build from source, because it fails finding
mariadb or mysql. During cross compilation, mysql_config does not work.
I've looked into it and we cannot make it work. The way to fix this is
using pkg-config. I've attached a patch that makes pure-ftpd try
pkg-config and then fall back to mysql_config. In order to apply it, you
need to regenerate configure and add a build dependency on pkg-config.
Once doing so, pure-ftpd will become cross buildable.

Helmut
--- pure-ftpd-1.0.49.orig/configure.ac
+++ pure-ftpd-1.0.49/configure.ac
@@ -1284,15 +1284,25 @@
 
 AC_ARG_WITH(mysql,
 [AS_HELP_STRING(--with-mysql,Users database is a MySQL database (see doc))],
-[ if test "x$withval" != "xno" ; then
-    if test "x$withval" != "x" && test "x$withval" != "xyes" ; then
+[ AS_IF([test "x$withval" != "xno"],[
+    AS_IF([test "x$withval" != "x" && test "x$withval" != "xyes"],[
       LD_RUN_PATH="${withval}/lib${LD_RUN_PATH:+:}${LD_RUN_PATH}"    
       LDFLAGS="$LDFLAGS -L${withval}/lib -L${withval}/lib/mysql -L${withval}/mysql/lib"
       CPPFLAGS="$CPPFLAGS -I${withval}/include -I${withval}/include/mysql -I${withval}/mysql/include"
-    else
-      CFLAGS="$CFLAGS `mariadb_config --cflags 2> /dev/null || mysql_config --cflags`"
-      LDFLAGS="$LDFLAGS `mariadb_config --libs 2> /dev/null || mysql_config --libs`"
-    fi
+    ],[
+      PKG_CHECK_MODULES([LIBMARIADB],[libmariadb],[
+        CFLAGS="$CFLAGS $LIBMARIADB_CFLAGS"
+	LDFLAGS="$LDFLAGS $LIBMARIADB_LIBS"
+      ],[
+	PKG_CHECK_MODULES([MYSQLCLIENT],[mysqlclient],[
+          CFLAGS="$CFLAGS $MYSQLCLIENT_CFLAGS"
+	  LDFLAGS="$LDFLAGS $MYSQLCLIENT_LIBS"
+	],[
+          CFLAGS="$CFLAGS `mariadb_config --cflags 2> /dev/null || mysql_config --cflags`"
+          LDFLAGS="$LDFLAGS `mariadb_config --libs 2> /dev/null || mysql_config --libs`"
+	])
+      ])
+    ])
     AC_CHECK_LIB(m, floor)
     AC_CHECK_LIB(z, gzclose)
     with_mysql="yes"
@@ -1317,7 +1327,7 @@
         AC_MSG_ERROR(Your MySQL client libraries aren't properly installed)
     ],[])
     AC_MSG_RESULT(yes)
-  fi ])
+  ]) ])
 
 AC_ARG_WITH(pgsql,
 [AS_HELP_STRING(--with-pgsql,Users database is a PostgreSQL database (see doc))],

Reply via email to