You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apr.apache.org by Peter Samuelson <pe...@p12n.org> on 2007/01/07 11:04:27 UTC

[PATCH] apr-util: fix dbd.m4 for use with apr_dbd_mysql.c

I was pleased to see that apr-util/build/dbd.m4 already accounts for
the externally-available apr_dbd_mysql.c - but it's slightly broken.
This is because the latter expects to see a definition of either
HAVE_MYSQL_H or HAVE_MYSQL_MYSQL_H.  autoheader _should_ be putting
those into include/private/apu_config.h.in, but it doesn't, because....

Well, after some wonderful quality time with autoconf, I discovered to
my infinite delight that autoheader picks up 'AC_CHECK_HEADERS' macros
but ignores 'AC_CHECK_HEADER' macros.

This patch takes that into account, and in the process cleans up dbd.m4
a bit.  Both of the -I flags that I removed (-I{/foo}/include/mysql and
-Iyes/include/myql) are unneeded.

Peter


--- apr-util/build/dbd.m4
+++ apr-util/build/dbd.m4
@@ -77,37 +77,24 @@
   ], [
     apu_have_mysql=0
     if test "$withval" = "yes"; then
-      AC_CHECK_HEADER(mysql.h, AC_CHECK_LIB(mysqlclient_r, mysql_init, [apu_have_mysql=1]))
-      if test "$apu_have_mysql" == "0"; then
-        AC_CHECK_HEADER(mysql/mysql.h, AC_CHECK_LIB(mysqlclient_r, mysql_init, [apu_have_mysql=1]))
-        if test "$apu_have_mysql" != "0"; then
-          APR_ADDTO(APRUTIL_INCLUDES, [-I$withval/include/myql])
-        fi
-      fi
-    elif test "$withval" = "no"; then
-      apu_have_mysql=0
-    else
+      AC_CHECK_HEADERS([mysql.h mysql/mysql.h],
+                       AC_CHECK_LIB(mysqlclient_r, mysql_init, [apu_have_mysql=1]))
+    elif test "$withval" != "no"; then
       CPPFLAGS="-I$withval/include"
       LIBS="-L$withval/lib "
 
       AC_MSG_NOTICE(checking for mysql in $withval)
-      AC_CHECK_HEADER(mysql.h, AC_CHECK_LIB(mysqlclient_r, mysql_init, [apu_have_mysql=1]))
+      AC_CHECK_HEADERS([mysql.h mysql/mysql.h],
+                       AC_CHECK_LIB(mysqlclient_r, mysql_init, [apu_have_mysql=1]))
       if test "$apu_have_mysql" != "0"; then
         APR_ADDTO(APRUTIL_LDFLAGS, [-L$withval/lib])
         APR_ADDTO(APRUTIL_INCLUDES, [-I$withval/include])
       fi
-
-      if test "$apu_have_mysql" != "1"; then
-        AC_CHECK_HEADER(mysql/mysql.h, AC_CHECK_LIB(mysqlclient_r, mysql_init, [apu_have_mysql=1]))
-        if test "$apu_have_mysql" != "0"; then
-          APR_ADDTO(APRUTIL_INCLUDES, [-I$withval/include/mysql])
-          APR_ADDTO(APRUTIL_LDFLAGS, [-L$withval/lib])
-        fi
-      fi
     fi
   ], [
     apu_have_mysql=0
-    AC_CHECK_HEADER(mysql.h, AC_CHECK_LIB(mysqlclient_r, mysql_init, [apu_have_mysql=1]))
+    AC_CHECK_HEADERS([mysql.h mysql/mysql.h],
+                     AC_CHECK_LIB(mysqlclient_r, mysql_init, [apu_have_mysql=1]))
   ])
 
   AC_SUBST(apu_have_mysql)

Re: [PATCH] apr-util: fix dbd.m4 for use with apr_dbd_mysql.c

Posted by Peter Samuelson <pe...@p12n.org>.
> It still doesn't work, but the reason is unrelated, I'll follow up
> separately.

Never mind that, it was user error.

Re: [PATCH] apr-util: fix dbd.m4 for use with apr_dbd_mysql.c

Posted by Peter Samuelson <pe...@p12n.org>.
My apologies, that patch was against 1.2.7, I forgot to check the
trunk.  I see you are already using AC_CHECK_HEADERS there, so the bug
that hit me is not present.  It still doesn't work, but the reason is
unrelated, I'll follow up separately.  Meanwhile, if you still want the
cleanup part....


Index: build/dbd.m4
===================================================================
--- build/dbd.m4	(revisione 492953)
+++ build/dbd.m4	(copia locale)
@@ -82,11 +82,10 @@
     AC_ARG_WITH([mysql], [
     --with-mysql=DIR          **** SEE INSTALL.MySQL ****
     ], [
-      apu_have_mysql=0
-      if test "$withval" = "yes"; then
-        old_cppflags="$CPPFLAGS"
-        old_ldflags="$LDFLAGS"
+      old_cppflags="$CPPFLAGS"
+      old_ldflags="$LDFLAGS"
 
+      if test "$withval" = "yes"; then
         AC_PATH_PROG([MYSQL_CONFIG],[mysql_config])
         if test "x$MYSQL_CONFIG" != 'x'; then
           mysql_CPPFLAGS="`$MYSQL_CONFIG --include`"
@@ -95,25 +94,13 @@
           APR_ADDTO(CPPFLAGS, [$mysql_CPPFLAGS])
           APR_ADDTO(LDFLAGS, [$mysql_LDFLAGS])
         fi
-
-        AC_CHECK_HEADERS(mysql.h, AC_CHECK_LIB(mysqlclient_r, mysql_init, [apu_have_mysql=1]))
-        if test "$apu_have_mysql" = "0"; then
-          AC_CHECK_HEADERS(mysql/mysql.h, AC_CHECK_LIB(mysqlclient_r, mysql_init, [apu_have_mysql=1]))
-        else
-          if test "x$MYSQL_CONFIG" != 'x'; then
-            APR_ADDTO(APRUTIL_INCLUDES, [$mysql_CPPFLAGS])
-            APR_ADDTO(APRUTIL_LDFLAGS, [$mysql_LDFLAGS])
-          fi
+        AC_CHECK_HEADERS([mysql.h mysql/mysql.h],
+                         AC_CHECK_LIB(mysqlclient_r, mysql_init, [apu_have_mysql=1]))
+        if test "$apu_have_mysql" = "1" && test "x$MYSQL_CONFIG" != 'x'; then
+          APR_ADDTO(APRUTIL_INCLUDES, [$mysql_CPPFLAGS])
+          APR_ADDTO(APRUTIL_LDFLAGS, [$mysql_LDFLAGS])
         fi
-
-        CPPFLAGS="$old_cppflags"
-        LDFLAGS="$old_ldflags"
-      elif test "$withval" = "no"; then
-        apu_have_mysql=0
-      else
-        old_cppflags="$CPPFLAGS"
-        old_ldflags="$LDFLAGS"
-
+      elif test "$withval" != "no"; then
         AC_PATH_PROG([MYSQL_CONFIG],[mysql_config],,[$withval/bin])
         if test "x$MYSQL_CONFIG" != 'x'; then
           mysql_CPPFLAGS="`$MYSQL_CONFIG --include`"
@@ -127,26 +114,17 @@
         APR_ADDTO(LDFLAGS, [$mysql_LDFLAGS])
 
         AC_MSG_NOTICE(checking for mysql in $withval)
-        AC_CHECK_HEADERS(mysql.h, AC_CHECK_LIB(mysqlclient_r, mysql_init, [apu_have_mysql=1]))
+        AC_CHECK_HEADERS([mysql.h mysql/mysql.h],
+                         AC_CHECK_LIB(mysqlclient_r, mysql_init, [apu_have_mysql=1]))
         if test "$apu_have_mysql" != "0"; then
           APR_ADDTO(APRUTIL_INCLUDES, [$mysql_CPPFLAGS])
           APR_ADDTO(APRUTIL_LDFLAGS, [$mysql_LDFLAGS])
         fi
-
-        if test "$apu_have_mysql" != "1"; then
-          AC_CHECK_HEADERS(mysql/mysql.h, AC_CHECK_LIB(mysqlclient_r, mysql_init, [apu_have_mysql=1]))
-          if test "$apu_have_mysql" != "0"; then
-            APR_ADDTO(APRUTIL_INCLUDES, [-I$withval/include/mysql])
-            APR_ADDTO(APRUTIL_LDFLAGS, [-L$withval/lib])
-          fi
-        fi
-
-        CPPFLAGS="$old_cppflags"
-        LDFLAGS="$old_ldflags"
       fi
-    ], [
-      apu_have_mysql=0
 
+      CPPFLAGS="$old_cppflags"
+      LDFLAGS="$old_ldflags"
+    ], [
       old_cppflags="$CPPFLAGS"
       old_ldflags="$LDFLAGS"
 
@@ -159,13 +137,12 @@
         APR_ADDTO(LDFLAGS, [$mysql_LDFLAGS])
       fi
 
-      AC_CHECK_HEADERS(mysql.h, AC_CHECK_LIB(mysqlclient_r, mysql_init, [apu_have_mysql=1]))
+      AC_CHECK_HEADERS([mysql.h mysql/mysql.h],
+                       AC_CHECK_LIB(mysqlclient_r, mysql_init, [apu_have_mysql=1]))
 
-      if test "$apu_have_mysql" != "0"; then
-        if test "x$MYSQL_CONFIG" != 'x'; then
-          APR_ADDTO(APRUTIL_INCLUDES, [$mysql_CPPFLAGS])
-          APR_ADDTO(APRUTIL_LDFLAGS, [$mysql_LDFLAGS])
-        fi
+      if test "$apu_have_mysql" != "0" && test "x$MYSQL_CONFIG" != 'x'; then
+        APR_ADDTO(APRUTIL_INCLUDES, [$mysql_CPPFLAGS])
+        APR_ADDTO(APRUTIL_LDFLAGS, [$mysql_LDFLAGS])
       fi
 
       CPPFLAGS="$old_cppflags"