Blame SOURCES/apr-util-mariadb-upstream.patch

bab188
Upstream patch for building with mariadb:
bab188
Taken from https://bz.apache.org/bugzilla/show_bug.cgi?id=61517
bab188
BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1494093
bab188
bab188
--- a/build/dbd.m4	2017-05-03 19:18:52.000000000 -0400
bab188
+++ a/build/dbd.m4	2017-09-13 16:58:07.369546391 -0400
bab188
@@ -163,10 +163,15 @@ 
bab188
   old_cppflags="$CPPFLAGS"
bab188
   old_ldflags="$LDFLAGS"
bab188
 
bab188
+  my_library="mysqlclient"
bab188
+
bab188
   AC_ARG_WITH([mysql], APR_HELP_STRING([--with-mysql=DIR], [enable MySQL DBD driver]),
bab188
   [
bab188
     if test "$withval" = "yes"; then
bab188
       AC_PATH_PROG([MYSQL_CONFIG],[mysql_config])
bab188
+      if test "x$MYSQL_CONFIG" = "x"; then
bab188
+        AC_PATH_PROG([MYSQL_CONFIG],[mariadb_config])
bab188
+      fi
bab188
       if test "x$MYSQL_CONFIG" != 'x'; then
bab188
         mysql_CPPFLAGS="`$MYSQL_CONFIG --include`"
bab188
         mysql_LDFLAGS="`$MYSQL_CONFIG --libs_r | sed -e 's/-l[[^ ]]\+//g'`"
bab188
@@ -174,32 +179,40 @@ 
bab188
 
bab188
         APR_ADDTO(CPPFLAGS, [$mysql_CPPFLAGS])
bab188
         APR_ADDTO(LIBS, [$mysql_LIBS])
bab188
+
bab188
+	if $MYSQL_CONFIG --libs_r | grep -q mariadb; then
bab188
+	  my_library="mariadb"
bab188
+	fi
bab188
       fi
bab188
 
bab188
-      AC_CHECK_HEADERS([mysql.h my_global.h my_sys.h],
bab188
-                       AC_CHECK_LIB(mysqlclient, mysql_init, [apu_have_mysql=1]),
bab188
-                       [apu_have_mysql=0; break],
bab188
-                       [#include <my_global.h>])
bab188
-      if test "$apu_have_mysql" = "0"; then
bab188
-        AC_CHECK_HEADERS([mysql/mysql.h mysql/my_global.h mysql/my_sys.h],
bab188
-                         AC_CHECK_LIB(mysqlclient, mysql_init, [apu_have_mysql=1]),
bab188
-                         [apu_have_mysql=0; break],
bab188
-                         [#include <mysql/my_global.h>])
bab188
+      AC_CHECK_HEADERS([mysql.h errmsg.h], [apu_have_mysql=1], [apu_have_mysql=0; break])
bab188
+      if test "$apr_have_mysql" = "0"; then
bab188
+	AC_CHECK_HEADERS([mysql/mysql.h mysql/errmsg.h], [apu_have_mysql=1], [apu_have_mysql=0; break])
bab188
       fi
bab188
-      if test "$apu_have_mysql" != "0" && test "x$MYSQL_CONFIG" != 'x'; then
bab188
-        APR_ADDTO(APRUTIL_PRIV_INCLUDES, [$mysql_CPPFLAGS])
bab188
+      if test "$apr_have_mysql" = "1"; then
bab188
+	AC_CHECK_HEADERS([my_global.h my_sys.h mysql/my_global.h mysql/my_sys.h])
bab188
+	AC_CHECK_LIB($my_library, mysql_init,, [apu_have_mysql=0])
bab188
+      fi
bab188
+      if test "$apu_have_mysql" = "1" && test "x$MYSQL_CONFIG" != 'x'; then
bab188
+	APR_ADDTO(APRUTIL_PRIV_INCLUDES, [$mysql_CPPFLAGS])
bab188
       fi
bab188
     elif test "$withval" = "no"; then
bab188
       :
bab188
     else
bab188
       AC_PATH_PROG([MYSQL_CONFIG],[mysql_config],,[$withval/bin])
bab188
+      if test "x$MYSQL_CONFIG" = "x"; then
bab188
+	AC_PATH_PROG([MYSQL_CONFIG],[mariadb_config],,[$withval/bin])
bab188
+      fi
bab188
       if test "x$MYSQL_CONFIG" != 'x'; then
bab188
-        mysql_CPPFLAGS="`$MYSQL_CONFIG --include`"
bab188
-        mysql_LDFLAGS="`$MYSQL_CONFIG --libs_r | sed -e 's/-l[[^ ]]\+//g'`"
bab188
-        mysql_LIBS="`$MYSQL_CONFIG --libs_r`"
bab188
+	mysql_CPPFLAGS="`$MYSQL_CONFIG --include`"
bab188
+	mysql_LDFLAGS="`$MYSQL_CONFIG --libs_r | sed -e 's/-l[[^ ]]\+//g'`"
bab188
+	mysql_LIBS="`$MYSQL_CONFIG --libs_r`"
bab188
+	if $MYSQL_CONFIG --libs_r | grep -q mariadb; then
bab188
+	  my_library="mariadb"
bab188
+	fi
bab188
       else
bab188
-        mysql_CPPFLAGS="-I$withval/include"
bab188
-        mysql_LDFLAGS="-L$withval/lib "
bab188
+	mysql_CPPFLAGS="-I$withval/include"
bab188
+	mysql_LDFLAGS="-L$withval/lib "
bab188
       fi
bab188
 
bab188
       APR_ADDTO(CPPFLAGS, [$mysql_CPPFLAGS])
bab188
@@ -207,18 +220,15 @@ 
bab188
       APR_ADDTO(LIBS, [$mysql_LIBS])
bab188
 
bab188
       AC_MSG_NOTICE(checking for mysql in $withval)
bab188
-      AC_CHECK_HEADERS([mysql.h my_global.h my_sys.h],
bab188
-                       AC_CHECK_LIB(mysqlclient, mysql_init, [apu_have_mysql=1]),
bab188
-                       [apu_have_mysql=0; break],
bab188
-                       [#include <my_global.h>])
bab188
-
bab188
-      if test "$apu_have_mysql" != "1"; then
bab188
-        AC_CHECK_HEADERS([mysql/mysql.h mysql/my_global.h mysql/my_sys.h],
bab188
-                         AC_CHECK_LIB(mysqlclient, mysql_init, [apu_have_mysql=1]),
bab188
-                         [apu_have_mysql=0; break],
bab188
-                         [#include <mysql/my_global.h>])
bab188
+      AC_CHECK_HEADERS([mysql.h errmsg.h], [apu_have_mysql=1], [apu_have_mysql=0; break])
bab188
+      if test "$apr_have_mysql" = "0"; then
bab188
+	AC_CHECK_HEADERS([mysql/mysql.h mysql/errmsg.h], [apu_have_mysql=1], [apu_have_mysql=0; break])
bab188
+      fi
bab188
+      if test "$apr_have_mysql" = "1"; then
bab188
+	AC_CHECK_HEADERS([my_global.h my_sys.h mysql/my_global.h mysql/my_sys.h])
bab188
+	AC_CHECK_LIB($my_library, mysql_init,, [apu_have_mysql=0])
bab188
       fi
bab188
-      if test "$apu_have_mysql" != "0"; then
bab188
+      if test "$apu_have_mysql" = "1"; then
bab188
         APR_ADDTO(APRUTIL_PRIV_INCLUDES, [$mysql_CPPFLAGS])
bab188
       fi
bab188
     fi
bab188
@@ -229,7 +239,7 @@ 
bab188
   dnl Since we have already done the AC_CHECK_LIB tests, if we have it, 
bab188
   dnl we know the library is there.
bab188
   if test "$apu_have_mysql" = "1"; then
bab188
-    APR_ADDTO(LDADD_dbd_mysql, [$mysql_LDFLAGS -lmysqlclient $mysql_LIBS])
bab188
+    APR_ADDTO(LDADD_dbd_mysql, [$mysql_LDFLAGS -l$my_library $mysql_LIBS])
bab188
   fi
bab188
   AC_SUBST(LDADD_dbd_mysql)
bab188
 
bab188
--- a/dbd/apr_dbd_mysql.c	2017-05-03 19:18:52.000000000 -0400
bab188
+++ a/dbd/apr_dbd_mysql.c	2017-09-13 19:15:20.894368809 -0400
bab188
@@ -1262,7 +1262,9 @@ 
bab188
 
bab188
 static void dbd_mysql_init(apr_pool_t *pool)
bab188
 {
bab188
+#if MYSQL_VERSION_ID < 100000
bab188
     my_init();
bab188
+#endif
bab188
     mysql_thread_init();
bab188
 
bab188
     /* FIXME: this is a guess; find out what it really does */
bab188