You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by bo...@apache.org on 2006/05/24 05:29:22 UTC

svn commit: r409059 - in /apr/apr-util/trunk: build/dbd.m4 dbd/apr_dbd_pgsql.c

Author: bojan
Date: Tue May 23 20:29:21 2006
New Revision: 409059

URL: http://svn.apache.org/viewvc?rev=409059&view=rev
Log:
Correct detection of various databases (PostgreSQL, MySQL, SQLite2/3, Oracle).
Use mysql_config to help detect required CPPFLAGS/LDFLAGS for MySQL.

Modified:
    apr/apr-util/trunk/build/dbd.m4
    apr/apr-util/trunk/dbd/apr_dbd_pgsql.c

Modified: apr/apr-util/trunk/build/dbd.m4
URL: http://svn.apache.org/viewvc/apr/apr-util/trunk/build/dbd.m4?rev=409059&r1=409058&r2=409059&view=diff
==============================================================================
--- apr/apr-util/trunk/build/dbd.m4 (original)
+++ apr/apr-util/trunk/build/dbd.m4 Tue May 23 20:29:21 2006
@@ -29,36 +29,42 @@
   ], [
     apu_have_pgsql=0
     if test "$withval" = "yes"; then
-      AC_CHECK_HEADER(libpq-fe.h, AC_CHECK_LIB(pq, PQsendQueryPrepared, [apu_have_pgsql=1]))
+      AC_CHECK_HEADERS(libpq-fe.h, AC_CHECK_LIB(pq, PQsendQueryPrepared, [apu_have_pgsql=1]))
       if test "$apu_have_pgsql" == "0"; then
-        AC_CHECK_HEADER(postgresql/libpq-fe.h, AC_CHECK_LIB(pq, PQsendQueryPrepared, [apu_have_pgsql=1]))
-        if test "$apu_have_pgsql" != "0"; then
-          APR_ADDTO(APRUTIL_INCLUDES, [-I$withval/include/postgresql])
-        fi
+        AC_CHECK_HEADERS(postgresql/libpq-fe.h, AC_CHECK_LIB(pq, PQsendQueryPrepared, [apu_have_pgsql=1]))
       fi
     elif test "$withval" = "no"; then
       apu_have_pgsql=0
     else
-      CPPFLAGS="-I$withval/include"
-      LDFLAGS="-L$withval/lib "
+      old_cppflags="$CPPFLAGS"
+      old_ldflags="$LDFLAGS"
+
+      pgsql_CPPFLAGS="-I$withval/include"
+      pgsql_LDFLAGS="-L$withval/lib "
+
+      APR_ADDTO(CPPFLAGS, [$pgsql_CPPFLAGS])
+      APR_ADDTO(LDFLAGS, [$pgsql_LDFLAGS])
 
       AC_MSG_NOTICE(checking for pgsql in $withval)
-      AC_CHECK_HEADER(libpq-fe.h, AC_CHECK_LIB(pq, PQsendQueryPrepared, [apu_have_pgsql=1]))
+      AC_CHECK_HEADERS(libpq-fe.h, AC_CHECK_LIB(pq, PQsendQueryPrepared, [apu_have_pgsql=1]))
       if test "$apu_have_pgsql" != "0"; then
         APR_ADDTO(APRUTIL_LDFLAGS, [-L$withval/lib])
         APR_ADDTO(APRUTIL_INCLUDES, [-I$withval/include])
       fi
       if test "$apu_have_pgsql" != "1"; then
-        AC_CHECK_HEADER(postgresql/libpq-fe.h, AC_CHECK_LIB(pq, PQsendQueryPrepared, [apu_have_pgsql=1]))
+        AC_CHECK_HEADERS(postgresql/libpq-fe.h, AC_CHECK_LIB(pq, PQsendQueryPrepared, [apu_have_pgsql=1]))
         if test "$apu_have_pgsql" != "0"; then
           APR_ADDTO(APRUTIL_INCLUDES, [-I$withval/include/postgresql])
           APR_ADDTO(APRUTIL_LDFLAGS, [-L$withval/lib])
         fi
       fi
+
+      CPPFLAGS="$old_cppflags"
+      LDFLAGS="$old_ldflags"
     fi
   ], [
     apu_have_pgsql=0
-    AC_CHECK_HEADER(libpq-fe.h, AC_CHECK_LIB(pq, PQsendQueryPrepared, [apu_have_pgsql=1]))
+    AC_CHECK_HEADERS(libpq-fe.h, AC_CHECK_LIB(pq, PQsendQueryPrepared, [apu_have_pgsql=1]))
   ])
   AC_SUBST(apu_have_pgsql)
   dnl Since we have already done the AC_CHECK_LIB tests, if we have it, 
@@ -77,37 +83,92 @@
   ], [
     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]))
+      old_cppflags="$CPPFLAGS"
+      old_ldflags="$LDFLAGS"
+
+      AC_PATH_PROG([MYSQL_CONFIG],[mysql_config])
+      if test "x$MYSQL_CONFIG" != 'x'; then
+        mysql_CPPFLAGS="`$MYSQL_CONFIG --include`"
+        mysql_LDFLAGS="`$MYSQL_CONFIG --libs_r`"
+
+        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_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])
+        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
       fi
+
+      CPPFLAGS="$old_cppflags"
+      LDFLAGS="$old_ldflags"
     elif test "$withval" = "no"; then
       apu_have_mysql=0
     else
-      CPPFLAGS="-I$withval/include"
-      LDFLAGS="-L$withval/lib "
+      old_cppflags="$CPPFLAGS"
+      old_ldflags="$LDFLAGS"
+
+      AC_PATH_PROG([MYSQL_CONFIG],[mysql_config],,[$withval/bin])
+      if test "x$MYSQL_CONFIG" != 'x'; then
+        mysql_CPPFLAGS="`$MYSQL_CONFIG --include`"
+        mysql_LDFLAGS="`$MYSQL_CONFIG --libs_r`"
+      else
+        mysql_CPPFLAGS="-I$withval/include"
+        mysql_LDFLAGS="-L$withval/lib "
+      fi
+
+      APR_ADDTO(CPPFLAGS, [$mysql_CPPFLAGS])
+      APR_ADDTO(LDFLAGS, [$mysql_LDFLAGS])
 
       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, 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])
+        APR_ADDTO(APRUTIL_INCLUDES, [$mysql_CPPFLAGS])
+        APR_ADDTO(APRUTIL_LDFLAGS, [$mysql_LDFLAGS])
       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]))
+        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
-    AC_CHECK_HEADER(mysql.h, AC_CHECK_LIB(mysqlclient_r, mysql_init, [apu_have_mysql=1]))
+
+    old_cppflags="$CPPFLAGS"
+    old_ldflags="$LDFLAGS"
+
+    AC_PATH_PROG([MYSQL_CONFIG],[mysql_config])
+    if test "x$MYSQL_CONFIG" != 'x'; then
+      mysql_CPPFLAGS="`$MYSQL_CONFIG --include`"
+      mysql_LDFLAGS="`$MYSQL_CONFIG --libs_r`"
+
+      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
+      if test "x$MYSQL_CONFIG" != 'x'; then
+        APR_ADDTO(APRUTIL_INCLUDES, [$mysql_CPPFLAGS])
+        APR_ADDTO(APRUTIL_LDFLAGS, [$mysql_LDFLAGS])
+      fi
+    fi
+
+    CPPFLAGS="$old_cppflags"
+    LDFLAGS="$old_ldflags"
   ])
 
   AC_SUBST(apu_have_mysql)
@@ -128,23 +189,32 @@
   ], [
     apu_have_sqlite3=0
     if test "$withval" = "yes"; then
-      AC_CHECK_HEADER(sqlite3.h, AC_CHECK_LIB(sqlite3, sqlite3_open, [apu_have_sqlite3=1]))
+      AC_CHECK_HEADERS(sqlite3.h, AC_CHECK_LIB(sqlite3, sqlite3_open, [apu_have_sqlite3=1]))
     elif test "$withval" = "no"; then
       apu_have_sqlite3=0
     else
-      CPPFLAGS="-I$withval/include"
-      LDFLAGS="-L$withval/lib "
+      old_cppflags="$CPPFLAGS"
+      old_ldflags="$LDFLAGS"
+
+      sqlite3_CPPFLAGS="-I$withval/include"
+      sqlite3_LDFLAGS="-L$withval/lib "
+
+      APR_ADDTO(CPPFLAGS, [$sqlite3_CPPFLAGS])
+      APR_ADDTO(LDFLAGS, [$sqlite3_LDFLAGS])
 
       AC_MSG_NOTICE(checking for sqlite3 in $withval)
-      AC_CHECK_HEADER(sqlite3.h, AC_CHECK_LIB(sqlite3, sqlite3_open, [apu_have_sqlite3=1]))
+      AC_CHECK_HEADERS(sqlite3.h, AC_CHECK_LIB(sqlite3, sqlite3_open, [apu_have_sqlite3=1]))
       if test "$apu_have_sqlite3" != "0"; then
         APR_ADDTO(APRUTIL_LDFLAGS, [-L$withval/lib])
         APR_ADDTO(APRUTIL_INCLUDES, [-I$withval/include])
       fi
+
+      CPPFLAGS="$old_cppflags"
+      LDFLAGS="$old_ldflags"
     fi
   ], [
     apu_have_sqlite3=0
-    AC_CHECK_HEADER(sqlite3.h, AC_CHECK_LIB(sqlite3, sqlite3_open, [apu_have_sqlite3=1]))
+    AC_CHECK_HEADERS(sqlite3.h, AC_CHECK_LIB(sqlite3, sqlite3_open, [apu_have_sqlite3=1]))
   ])
 
   AC_SUBST(apu_have_sqlite3)
@@ -165,23 +235,32 @@
   ], [
     apu_have_sqlite2=0
     if test "$withval" = "yes"; then
-      AC_CHECK_HEADER(sqlite.h, AC_CHECK_LIB(sqlite, sqlite_open, [apu_have_sqlite2=1]))
+      AC_CHECK_HEADERS(sqlite.h, AC_CHECK_LIB(sqlite, sqlite_open, [apu_have_sqlite2=1]))
     elif test "$withval" = "no"; then
       apu_have_sqlite2=0
     else
-      CPPFLAGS="-I$withval/include"
-      LDFLAGS="-L$withval/lib "
+      old_cppflags="$CPPFLAGS"
+      old_ldflags="$LDFLAGS"
+
+      sqlite2_CPPFLAGS="-I$withval/include"
+      sqlite2_LDFLAGS="-L$withval/lib "
+
+      APR_ADDTO(CPPFLAGS, [$sqlite2_CPPFLAGS])
+      APR_ADDTO(LDFLAGS, [$sqlite2_LDFLAGS])
 
       AC_MSG_NOTICE(checking for sqlite2 in $withval)
-      AC_CHECK_HEADER(sqlite.h, AC_CHECK_LIB(sqlite, sqlite_open, [apu_have_sqlite2=1]))
+      AC_CHECK_HEADERS(sqlite.h, AC_CHECK_LIB(sqlite, sqlite_open, [apu_have_sqlite2=1]))
       if test "$apu_have_sqlite2" != "0"; then
         APR_ADDTO(APRUTIL_LDFLAGS, [-L$withval/lib])
         APR_ADDTO(APRUTIL_INCLUDES, [-I$withval/include])
       fi
+
+      CPPFLAGS="$old_cppflags"
+      LDFLAGS="$old_ldflags"
     fi
   ], [
     apu_have_sqlite2=0
-    AC_CHECK_HEADER(sqlite.h, AC_CHECK_LIB(sqlite, sqlite_open, [apu_have_sqlite2=1]))
+    AC_CHECK_HEADERS(sqlite.h, AC_CHECK_LIB(sqlite, sqlite_open, [apu_have_sqlite2=1]))
   ])
 
   AC_SUBST(apu_have_sqlite2)
@@ -202,25 +281,34 @@
   ], [
     apu_have_oracle=0
     if test "$withval" = "yes"; then
-      AC_CHECK_HEADER(oci.h, AC_CHECK_LIB(clntsh, OCIEnvCreate, [apu_have_oracle=1]))
+      AC_CHECK_HEADERS(oci.h, AC_CHECK_LIB(clntsh, OCIEnvCreate, [apu_have_oracle=1]))
     elif test "$withval" = "no"; then
       apu_have_oracle=0
     else
-      CPPFLAGS="-I$withval/rdbms/demo -I$withval/rdbms/public"
-      LDFLAGS="-L$withval/lib "
+      old_cppflags="$CPPFLAGS"
+      old_ldflags="$LDFLAGS"
+
+      oracle_CPPFLAGS="-I$withval/rdbms/demo -I$withval/rdbms/public"
+      oracle_LDFLAGS="-L$withval/lib "
+
+      APR_ADDTO(CPPFLAGS, [$oracle_CPPFLAGS])
+      APR_ADDTO(LDFLAGS, [$oracle_LDFLAGS])
 
       AC_MSG_NOTICE(checking for oracle in $withval)
-      AC_CHECK_HEADER(oci.h, AC_CHECK_LIB(clntsh, OCIEnvCreate, [apu_have_oracle=1]))
+      AC_CHECK_HEADERS(oci.h, AC_CHECK_LIB(clntsh, OCIEnvCreate, [apu_have_oracle=1]))
       if test "$apu_have_oracle" != "0"; then
         APR_ADDTO(APRUTIL_LDFLAGS, [-L$withval/lib])
         APR_ADDTO(APRUTIL_LDFLAGS, [-R$withval/lib])
         APR_ADDTO(APRUTIL_INCLUDES, [-I$withval/rdbms/demo])
         APR_ADDTO(APRUTIL_INCLUDES, [-I$withval/rdbms/public])
       fi
+
+      CPPFLAGS="$old_cppflags"
+      LDFLAGS="$old_ldflags"
     fi
   ], [
     apu_have_oracle=0
-    AC_CHECK_HEADER(oci.h, AC_CHECK_LIB(clntsh, OCIEnvCreate, [apu_have_oracle=1]))
+    AC_CHECK_HEADERS(oci.h, AC_CHECK_LIB(clntsh, OCIEnvCreate, [apu_have_oracle=1]))
   ])
 
   AC_SUBST(apu_have_oracle)

Modified: apr/apr-util/trunk/dbd/apr_dbd_pgsql.c
URL: http://svn.apache.org/viewvc/apr/apr-util/trunk/dbd/apr_dbd_pgsql.c?rev=409059&r1=409058&r2=409059&view=diff
==============================================================================
--- apr/apr-util/trunk/dbd/apr_dbd_pgsql.c (original)
+++ apr/apr-util/trunk/dbd/apr_dbd_pgsql.c Tue May 23 20:29:21 2006
@@ -18,10 +18,16 @@
 
 #if APU_HAVE_PGSQL
 
+#include "apu_config.h"
+
 #include <ctype.h>
 #include <stdlib.h>
 
+#ifdef HAVE_LIBPQ_FE_H
 #include <libpq-fe.h>
+#elif defined(HAVE_POSTGRESQL_LIBPQ_FE_H)
+#include <postgresql/libpq-fe.h>
+#endif
 
 #include "apr_strings.h"
 #include "apr_time.h"