On Mon, 2006-05-22 at 11:12 +0100, Joe Orton wrote:
> Hi Bojan - some comments on the autoconf code:
Here is a patch that hopefully deals with the issues you mentioned in
the new code, as well as the stuff that was already in dbd.m4. I tested
this on FC5 (i386) and it seems to work for PostgreSQL, SQLite3 and
MySQL.
--
Bojan
Index: build/dbd.m4
===================================================================
--- build/dbd.m4 (revision 408793)
+++ build/dbd.m4 (working copy)
@@ -33,15 +33,21 @@
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])
+ APR_ADDTO(APRUTIL_INCLUDES, [-I/usr/include/postgresql])
fi
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]))
if test "$apu_have_pgsql" != "0"; then
@@ -55,6 +61,9 @@
APR_ADDTO(APRUTIL_LDFLAGS, [-L$withval/lib])
fi
fi
+
+ CPPFLAGS="$old_cppflags"
+ LDFLAGS="$old_ldflags"
fi
], [
apu_have_pgsql=0
@@ -77,24 +86,56 @@
], [
apu_have_mysql=0
if test "$withval" = "yes"; then
+ 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_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/mysql])
+ APR_ADDTO(APRUTIL_INCLUDES, [-I/usr/include/mysql])
fi
+ 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]))
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
@@ -104,10 +145,36 @@
APR_ADDTO(APRUTIL_LDFLAGS, [-L$withval/lib])
fi
fi
+
+ CPPFLAGS="$old_cppflags"
+ LDFLAGS="$old_ldflags"
fi
], [
apu_have_mysql=0
+
+ 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_HEADER(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)
@@ -132,15 +199,24 @@
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]))
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
@@ -169,15 +245,24 @@
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]))
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
@@ -206,9 +291,15 @@
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]))
if test "$apu_have_oracle" != "0"; then
@@ -217,6 +308,9 @@
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