--- apr-util.orig/build/dbd.m4
+++ apr-util/build/dbd.m4
@@ -176,10 +176,15 @@ AC_DEFUN([APU_CHECK_DBD_MYSQL], [
         APR_ADDTO(LIBS, [$mysql_LIBS])
       fi
 
+      AC_LINK_IFELSE([#include <my_global.h>
+                      int main(int a, char **b) { mysql_init(); return 0; }],
+                     [apu_have_mysql=1], [apu_have_mysql=0])
+      if test "$apu_have_mysql" = "0"; then
       AC_CHECK_HEADERS([mysql.h my_global.h my_sys.h],
                        AC_CHECK_LIB(mysqlclient_r, mysql_init, [apu_have_mysql=1]),
                        [apu_have_mysql=0; break],
                        [#include <my_global.h>])
+      fi
       if test "$apu_have_mysql" = "0"; then
         AC_CHECK_HEADERS([mysql/mysql.h mysql/my_global.h mysql/my_sys.h],
                          AC_CHECK_LIB(mysqlclient_r, mysql_init, [apu_have_mysql=1]),
@@ -207,11 +212,16 @@ AC_DEFUN([APU_CHECK_DBD_MYSQL], [
       APR_ADDTO(LIBS, [$mysql_LIBS])
 
       AC_MSG_NOTICE(checking for mysql in $withval)
+      AC_LINK_IFELSE([#include <my_global.h>
+                      int main(int a, char **b) { mysql_init(); return 0; }],
+                     [apu_have_mysql=1], [apu_have_mysql=0])
+      if test "$apu_have_mysql" != "1"; then
       AC_CHECK_HEADERS([mysql.h my_global.h my_sys.h],
                        AC_CHECK_LIB(mysqlclient_r, mysql_init, [apu_have_mysql=1]),
                        [apu_have_mysql=0; break],
                        [#include <my_global.h>])
 
+      fi
       if test "$apu_have_mysql" != "1"; then
         AC_CHECK_HEADERS([mysql/mysql.h mysql/my_global.h mysql/my_sys.h],
                          AC_CHECK_LIB(mysqlclient_r, mysql_init, [apu_have_mysql=1]),
@@ -229,7 +239,7 @@ AC_DEFUN([APU_CHECK_DBD_MYSQL], [
   dnl Since we have already done the AC_CHECK_LIB tests, if we have it, 
   dnl we know the library is there.
   if test "$apu_have_mysql" = "1"; then
-    APR_ADDTO(LDADD_dbd_mysql, [$mysql_LDFLAGS -lmysqlclient_r $mysql_LIBS])
+    APR_ADDTO(LDADD_dbd_mysql, [$mysql_LDFLAGS $mysql_LIBS])
   fi
   AC_SUBST(LDADD_dbd_mysql)
 
