apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bo...@apache.org
Subject svn commit: r409065 - in /apr/apr-util/branches/1.2.x: build/dbd.m4 dbd/apr_dbd_pgsql.c
Date Wed, 24 May 2006 04:12:04 GMT
Author: bojan
Date: Tue May 23 21:12:03 2006
New Revision: 409065

URL: http://svn.apache.org/viewvc?rev=409065&view=rev
Log:
Rework r409059 from the trunk to apply to 1.2.x branch.
Correct detection of various databases (PostgreSQL, MySQL, SQLite2/3).
Use mysql_config to help detect required CPPFLAGS/LDFLAGS for MySQL.

Modified:
    apr/apr-util/branches/1.2.x/build/dbd.m4
    apr/apr-util/branches/1.2.x/dbd/apr_dbd_pgsql.c

Modified: apr/apr-util/branches/1.2.x/build/dbd.m4
URL: http://svn.apache.org/viewvc/apr/apr-util/branches/1.2.x/build/dbd.m4?rev=409065&r1=409064&r2=409065&view=diff
==============================================================================
--- apr/apr-util/branches/1.2.x/build/dbd.m4 (original)
+++ apr/apr-util/branches/1.2.x/build/dbd.m4 Tue May 23 21:12:03 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"
-      LIBS="-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/myql])
+        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"
-      LIBS="-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"
-      LIBS="-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"
-      LIBS="-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)

Modified: apr/apr-util/branches/1.2.x/dbd/apr_dbd_pgsql.c
URL: http://svn.apache.org/viewvc/apr/apr-util/branches/1.2.x/dbd/apr_dbd_pgsql.c?rev=409065&r1=409064&r2=409065&view=diff
==============================================================================
--- apr/apr-util/branches/1.2.x/dbd/apr_dbd_pgsql.c (original)
+++ apr/apr-util/branches/1.2.x/dbd/apr_dbd_pgsql.c Tue May 23 21:12:03 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"



Mime
View raw message