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