summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbojan <bojan@13f79535-47bb-0310-9956-ffa450edef68>2006-05-24 03:29:21 +0000
committerbojan <bojan@13f79535-47bb-0310-9956-ffa450edef68>2006-05-24 03:29:21 +0000
commit91813fd64a6003d7f32a5dedf42d5464cba1a1d9 (patch)
tree24c73a895e902e40f1703aa48ebe5707448b3a9a
parent905cd9742e3e83804b8f4e8150923ecf1beb7b60 (diff)
downloadlibapr-util-91813fd64a6003d7f32a5dedf42d5464cba1a1d9.tar.gz
Correct detection of various databases (PostgreSQL, MySQL, SQLite2/3, Oracle).
Use mysql_config to help detect required CPPFLAGS/LDFLAGS for MySQL. git-svn-id: http://svn.apache.org/repos/asf/apr/apr-util/trunk@409059 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--build/dbd.m4160
-rw-r--r--dbd/apr_dbd_pgsql.c6
2 files changed, 130 insertions, 36 deletions
diff --git a/build/dbd.m4 b/build/dbd.m4
index 07f5bb42..964698f2 100644
--- a/build/dbd.m4
+++ b/build/dbd.m4
@@ -29,36 +29,42 @@ AC_DEFUN([APU_CHECK_DBD], [
], [
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 @@ AC_DEFUN([APU_CHECK_DBD_MYSQL], [
], [
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 @@ AC_DEFUN([APU_CHECK_DBD_SQLITE3], [
], [
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 @@ AC_DEFUN([APU_CHECK_DBD_SQLITE2], [
], [
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 @@ AC_DEFUN([APU_CHECK_DBD_ORACLE], [
], [
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)
diff --git a/dbd/apr_dbd_pgsql.c b/dbd/apr_dbd_pgsql.c
index 032ec7f1..21508930 100644
--- a/dbd/apr_dbd_pgsql.c
+++ b/dbd/apr_dbd_pgsql.c
@@ -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"