1 dnl -------------------------------------------------------- -*- autoconf -*-
2 dnl Copyright 2005 The Apache Software Foundation or its licensors, as
5 dnl Licensed under the Apache License, Version 2.0 (the "License");
6 dnl you may not use this file except in compliance with the License.
7 dnl You may obtain a copy of the License at
9 dnl http://www.apache.org/licenses/LICENSE-2.0
11 dnl Unless required by applicable law or agreed to in writing, software
12 dnl distributed under the License is distributed on an "AS IS" BASIS,
13 dnl WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 dnl See the License for the specific language governing permissions and
15 dnl limitations under the License.
22 dnl APU_CHECK_DBD: compile backends for apr_dbd.
24 AC_DEFUN([APU_CHECK_DBD], [
28 old_cppflags="$CPPFLAGS"
29 old_ldflags="$LDFLAGS"
31 AC_ARG_WITH([pgsql], APR_HELP_STRING([--with-pgsql=DIR], [specify PostgreSQL location]),
33 if test "$withval" = "yes"; then
34 AC_PATH_PROG([PGSQL_CONFIG],[pg_config])
35 if test "x$PGSQL_CONFIG" != 'x'; then
36 pgsql_CPPFLAGS="-I`$PGSQL_CONFIG --includedir`"
37 pgsql_LDFLAGS="`$PGSQL_CONFIG --libs`"
39 APR_ADDTO(CPPFLAGS, [$pgsql_CPPFLAGS])
40 APR_ADDTO(LDFLAGS, [$pgsql_LDFLAGS])
43 AC_CHECK_HEADERS(libpq-fe.h, AC_CHECK_LIB(pq, PQsendQueryPrepared, [apu_have_pgsql=1]))
44 if test "$apu_have_pgsql" = "0"; then
45 AC_CHECK_HEADERS(postgresql/libpq-fe.h, AC_CHECK_LIB(pq, PQsendQueryPrepared, [apu_have_pgsql=1]))
47 elif test "$withval" = "no"; then
50 AC_PATH_PROG([PGSQL_CONFIG],[pg_config],,[$withval/bin])
51 if test "x$PGSQL_CONFIG" != 'x'; then
52 pgsql_CPPFLAGS="-I`$PGSQL_CONFIG --includedir`"
53 pgsql_LDFLAGS="`$PGSQL_CONFIG --libs`"
55 pgsql_CPPFLAGS="-I$withval/include"
56 pgsql_LDFLAGS="-L$withval/lib "
59 APR_ADDTO(CPPFLAGS, [$pgsql_CPPFLAGS])
60 APR_ADDTO(LDFLAGS, [$pgsql_LDFLAGS])
62 AC_MSG_NOTICE(checking for pgsql in $withval)
63 AC_CHECK_HEADERS(libpq-fe.h, AC_CHECK_LIB(pq, PQsendQueryPrepared, [apu_have_pgsql=1]))
64 if test "$apu_have_pgsql" != "0"; then
65 APR_ADDTO(APRUTIL_LDFLAGS, [-L$withval/lib])
66 APR_ADDTO(APRUTIL_INCLUDES, [-I$withval/include])
68 if test "$apu_have_pgsql" != "1"; then
69 AC_CHECK_HEADERS(postgresql/libpq-fe.h, AC_CHECK_LIB(pq, PQsendQueryPrepared, [apu_have_pgsql=1]))
70 if test "$apu_have_pgsql" != "0"; then
71 APR_ADDTO(APRUTIL_INCLUDES, [-I$withval/include/postgresql])
72 APR_ADDTO(APRUTIL_LDFLAGS, [-L$withval/lib])
77 AC_PATH_PROG([PGSQL_CONFIG],[pg_config])
78 if test "x$PGSQL_CONFIG" != 'x'; then
79 pgsql_CPPFLAGS="-I`$PGSQL_CONFIG --includedir`"
80 pgsql_LDFLAGS="`$PGSQL_CONFIG --libs`"
82 APR_ADDTO(CPPFLAGS, [$pgsql_CPPFLAGS])
83 APR_ADDTO(LDFLAGS, [$pgsql_LDFLAGS])
86 AC_CHECK_HEADERS(libpq-fe.h, AC_CHECK_LIB(pq, PQsendQueryPrepared, [apu_have_pgsql=1]))
87 if test "$apu_have_pgsql" = "0"; then
88 AC_CHECK_HEADERS(postgresql/libpq-fe.h, AC_CHECK_LIB(pq, PQsendQueryPrepared, [apu_have_pgsql=1]))
91 AC_SUBST(apu_have_pgsql)
92 dnl Since we have already done the AC_CHECK_LIB tests, if we have it,
93 dnl we know the library is there.
94 if test "$apu_have_pgsql" = "1"; then
97 AC_SUBST(LDADD_dbd_pgsql)
100 CPPFLAGS="$old_cppflags"
101 LDFLAGS="$old_ldflags"
104 AC_DEFUN([APU_CHECK_DBD_MYSQL], [
108 old_cppflags="$CPPFLAGS"
109 old_ldflags="$LDFLAGS"
111 AC_ARG_WITH([mysql], APR_HELP_STRING([--with-mysql=DIR], [enable MySQL DBD driver]),
113 if test "$withval" = "yes"; then
114 AC_PATH_PROG([MYSQL_CONFIG],[mysql_config])
115 if test "x$MYSQL_CONFIG" != 'x'; then
116 mysql_CPPFLAGS="`$MYSQL_CONFIG --include`"
117 mysql_LDFLAGS="`$MYSQL_CONFIG --libs_r`"
119 APR_ADDTO(CPPFLAGS, [$mysql_CPPFLAGS])
120 APR_ADDTO(LDFLAGS, [$mysql_LDFLAGS])
123 AC_CHECK_HEADERS(mysql.h, AC_CHECK_LIB(mysqlclient_r, mysql_init, [apu_have_mysql=1]))
124 if test "$apu_have_mysql" = "0"; then
125 AC_CHECK_HEADERS(mysql/mysql.h, AC_CHECK_LIB(mysqlclient_r, mysql_init, [apu_have_mysql=1]))
127 if test "x$MYSQL_CONFIG" != 'x'; then
128 APR_ADDTO(APRUTIL_INCLUDES, [$mysql_CPPFLAGS])
131 elif test "$withval" = "no"; then
134 AC_PATH_PROG([MYSQL_CONFIG],[mysql_config],,[$withval/bin])
135 if test "x$MYSQL_CONFIG" != 'x'; then
136 mysql_CPPFLAGS="`$MYSQL_CONFIG --include`"
137 mysql_LDFLAGS="`$MYSQL_CONFIG --libs_r`"
139 mysql_CPPFLAGS="-I$withval/include"
140 mysql_LDFLAGS="-L$withval/lib "
143 APR_ADDTO(CPPFLAGS, [$mysql_CPPFLAGS])
144 APR_ADDTO(LDFLAGS, [$mysql_LDFLAGS])
146 AC_MSG_NOTICE(checking for mysql in $withval)
147 AC_CHECK_HEADERS(mysql.h, AC_CHECK_LIB(mysqlclient_r, mysql_init, [apu_have_mysql=1]))
148 if test "$apu_have_mysql" != "0"; then
149 APR_ADDTO(APRUTIL_INCLUDES, [$mysql_CPPFLAGS])
152 if test "$apu_have_mysql" != "1"; then
153 AC_CHECK_HEADERS(mysql/mysql.h, AC_CHECK_LIB(mysqlclient_r, mysql_init, [apu_have_mysql=1]))
154 if test "$apu_have_mysql" != "0"; then
155 APR_ADDTO(APRUTIL_INCLUDES, [-I$withval/include/mysql])
161 AC_SUBST(apu_have_mysql)
163 dnl Since we have already done the AC_CHECK_LIB tests, if we have it,
164 dnl we know the library is there.
165 if test "$apu_have_mysql" = "1"; then
166 LDADD_dbd_mysql=$mysql_LDFLAGS
168 AC_SUBST(LDADD_dbd_mysql)
171 CPPFLAGS="$old_cppflags"
172 LDFLAGS="$old_ldflags"
175 AC_DEFUN([APU_CHECK_DBD_SQLITE3], [
179 old_cppflags="$CPPFLAGS"
180 old_ldflags="$LDFLAGS"
182 AC_ARG_WITH([sqlite3], APR_HELP_STRING([--with-sqlite3=DIR], [enable sqlite3 DBD driver]),
184 if test "$withval" = "yes"; then
185 AC_CHECK_HEADERS(sqlite3.h, AC_CHECK_LIB(sqlite3, sqlite3_open, [apu_have_sqlite3=1]))
186 elif test "$withval" = "no"; then
189 sqlite3_CPPFLAGS="-I$withval/include"
190 sqlite3_LDFLAGS="-L$withval/lib "
192 APR_ADDTO(CPPFLAGS, [$sqlite3_CPPFLAGS])
193 APR_ADDTO(LDFLAGS, [$sqlite3_LDFLAGS])
195 AC_MSG_NOTICE(checking for sqlite3 in $withval)
196 AC_CHECK_HEADERS(sqlite3.h, AC_CHECK_LIB(sqlite3, sqlite3_open, [apu_have_sqlite3=1]))
197 if test "$apu_have_sqlite3" != "0"; then
198 APR_ADDTO(APRUTIL_LDFLAGS, [-L$withval/lib])
199 APR_ADDTO(APRUTIL_INCLUDES, [-I$withval/include])
203 AC_CHECK_HEADERS(sqlite3.h, AC_CHECK_LIB(sqlite3, sqlite3_open, [apu_have_sqlite3=1]))
206 AC_SUBST(apu_have_sqlite3)
208 dnl Since we have already done the AC_CHECK_LIB tests, if we have it,
209 dnl we know the library is there.
210 if test "$apu_have_sqlite3" = "1"; then
211 LDADD_dbd_sqlite3="-lsqlite3"
213 AC_SUBST(LDADD_dbd_sqlite3)
216 CPPFLAGS="$old_cppflags"
217 LDFLAGS="$old_ldflags"
220 AC_DEFUN([APU_CHECK_DBD_SQLITE2], [
224 old_cppflags="$CPPFLAGS"
225 old_ldflags="$LDFLAGS"
227 AC_ARG_WITH([sqlite2], APR_HELP_STRING([--with-sqlite2=DIR], [enable sqlite2 DBD driver]),
229 if test "$withval" = "yes"; then
230 AC_CHECK_HEADERS(sqlite.h, AC_CHECK_LIB(sqlite, sqlite_open, [apu_have_sqlite2=1]))
231 elif test "$withval" = "no"; then
234 sqlite2_CPPFLAGS="-I$withval/include"
235 sqlite2_LDFLAGS="-L$withval/lib "
237 APR_ADDTO(CPPFLAGS, [$sqlite2_CPPFLAGS])
238 APR_ADDTO(LDFLAGS, [$sqlite2_LDFLAGS])
240 AC_MSG_NOTICE(checking for sqlite2 in $withval)
241 AC_CHECK_HEADERS(sqlite.h, AC_CHECK_LIB(sqlite, sqlite_open, [apu_have_sqlite2=1]))
242 if test "$apu_have_sqlite2" != "0"; then
243 APR_ADDTO(APRUTIL_LDFLAGS, [-L$withval/lib])
244 APR_ADDTO(APRUTIL_INCLUDES, [-I$withval/include])
248 AC_CHECK_HEADERS(sqlite.h, AC_CHECK_LIB(sqlite, sqlite_open, [apu_have_sqlite2=1]))
251 AC_SUBST(apu_have_sqlite2)
253 dnl Since we have already done the AC_CHECK_LIB tests, if we have it,
254 dnl we know the library is there.
255 if test "$apu_have_sqlite2" = "1"; then
256 LDADD_dbd_sqlite2="-lsqlite"
258 AC_SUBST(LDADD_dbd_sqlite2)
261 CPPFLAGS="$old_cppflags"
262 LDFLAGS="$old_ldflags"
265 AC_DEFUN([APU_CHECK_DBD_ORACLE], [
269 old_cppflags="$CPPFLAGS"
270 old_ldflags="$LDFLAGS"
272 AC_ARG_WITH([oracle-include],
273 APR_HELP_STRING([--with-oracle-include=DIR], [path to Oracle include files]))
274 AC_ARG_WITH([oracle],
275 APR_HELP_STRING([--with-oracle=DIR], [enable Oracle DBD driver; giving ORACLE_HOME as DIR]),
277 if test "$withval" = "yes"; then
278 if test -n "$with_oracle_include"; then
279 oracle_CPPFLAGS="$CPPFLAGS -I$with_oracle_include"
280 APR_ADDTO(APRUTIL_INCLUDES, [-I$with_oracle_include])
283 APR_ADDTO(CPPFLAGS, [$oracle_CPPFLAGS])
285 AC_CHECK_HEADERS(oci.h, AC_CHECK_LIB(clntsh, OCIEnvCreate, [apu_have_oracle=1],[
286 unset ac_cv_lib_clntsh_OCIEnvCreate
287 AC_CHECK_LIB(clntsh, OCIEnvCreate, [
289 LDADD_dbd_oracle="-lnnz10"
292 elif test "$withval" = "no"; then
295 if test -n "$with_oracle_include"; then
296 oracle_CPPFLAGS="$CPPFLAGS -I$with_oracle_include"
297 APR_ADDTO(APRUTIL_INCLUDES, [-I$with_oracle_include])
299 oracle_CPPFLAGS="-I$withval/rdbms/demo -I$withval/rdbms/public"
301 oracle_LDFLAGS="-L$withval/lib "
303 APR_ADDTO(CPPFLAGS, [$oracle_CPPFLAGS])
304 APR_ADDTO(LDFLAGS, [$oracle_LDFLAGS])
306 AC_MSG_NOTICE(checking for oracle in $withval)
307 AC_CHECK_HEADERS(oci.h, AC_CHECK_LIB(clntsh, OCIEnvCreate, [apu_have_oracle=1],[
308 unset ac_cv_lib_clntsh_OCIEnvCreate
309 AC_CHECK_LIB(clntsh, OCIEnvCreate, [
311 LDADD_dbd_oracle="-lnnz10"
314 if test "$apu_have_oracle" != "0"; then
315 APR_ADDTO(APRUTIL_LDFLAGS, [-L$withval/lib])
316 APR_ADDTO(APRUTIL_LDFLAGS, [-R$withval/lib])
317 if test -z "$with_oracle_include"; then
318 APR_ADDTO(APRUTIL_INCLUDES, [-I$withval/rdbms/demo])
319 APR_ADDTO(APRUTIL_INCLUDES, [-I$withval/rdbms/public])
325 AC_SUBST(apu_have_oracle)
327 dnl Since we have already done the AC_CHECK_LIB tests, if we have it,
328 dnl we know the library is there.
329 if test "$apu_have_oracle" = "1"; then
330 LDADD_dbd_oracle="$LDADD_dbd_oracle -lclntsh"
332 AC_SUBST(LDADD_dbd_oracle)
335 CPPFLAGS="$old_cppflags"
336 LDFLAGS="$old_ldflags"
340 AC_DEFUN([APU_CHECK_DBD_FREETDS], [
344 old_cppflags="$CPPFLAGS"
345 old_ldflags="$LDFLAGS"
347 AC_ARG_WITH([freetds],
348 APR_HELP_STRING([--with-freetds=DIR], [specify FreeTDS location]),
350 if test "$withval" = "yes"; then
351 AC_CHECK_HEADERS(sybdb.h, AC_CHECK_LIB(sybdb, tdsdbopen, [apu_have_freetds=1]))
352 elif test "$withval" = "no"; then
355 sybdb_CPPFLAGS="-I$withval/include"
356 sybdb_LDFLAGS="-L$withval/lib "
358 APR_ADDTO(CPPFLAGS, [$sybdb_CPPFLAGS])
359 APR_ADDTO(LDFLAGS, [$sybdb_LDFLAGS])
361 AC_MSG_NOTICE(checking for freetds in $withval)
362 AC_CHECK_HEADERS(sybdb.h, AC_CHECK_LIB(sybdb, tdsdbopen, [apu_have_freetds=1]))
363 if test "$apu_have_freetds" != "0"; then
364 APR_ADDTO(APRUTIL_LDFLAGS, [-L$withval/lib])
365 APR_ADDTO(APRUTIL_INCLUDES, [-I$withval/include])
369 AC_CHECK_HEADERS(sybdb.h, AC_CHECK_LIB(sybdb, tdsdbopen, [apu_have_freetds=1]))
372 AC_SUBST(apu_have_freetds)
374 dnl Since we have already done the AC_CHECK_LIB tests, if we have it,
375 dnl we know the library is there.
376 if test "$apu_have_freetds" = "1"; then
377 LDADD_dbd_freetds="$LDADD_dbd_freetds -lsybdb"
378 dnl Erm, I needed pcreposix, but I think that dependency has gone
379 dnl from the current code
380 dnl LDADD_dbd_freetds="$LDADD_dbd_freetds -lsybdb -lpcreposix"
382 AC_SUBST(LDADD_dbd_freetds)
385 CPPFLAGS="$old_cppflags"
386 LDFLAGS="$old_ldflags"
390 AC_DEFUN([APU_CHECK_DBD_DSO], [
392 AC_ARG_ENABLE([dbd-dso],
393 APR_HELP_STRING([--disable-dbd-dso], [disable DSO build of DBD drivers]))
395 if test "$enable_dbd_dso" = "no"; then
396 # Statically link the DBD drivers:
399 test $apu_have_oracle = 1 && objs="$objs dbd/apr_dbd_oracle.lo"
400 test $apu_have_pgsql = 1 && objs="$objs dbd/apr_dbd_pgsql.lo"
401 test $apu_have_mysql = 1 && objs="$objs dbd/apr_dbd_mysql.lo"
402 test $apu_have_sqlite2 = 1 && objs="$objs dbd/apr_dbd_sqlite2.lo"
403 test $apu_have_sqlite3 = 1 && objs="$objs dbd/apr_dbd_sqlite3.lo"
404 test $apu_have_freetds = 1 && objs="$objs dbd/apr_dbd_freetds.lo"
405 EXTRA_OBJECTS="$EXTRA_OBJECTS $objs"
407 # Use libtool *.la for mysql if available
408 if test $apu_have_mysql = 1; then
409 for flag in $LDADD_dbd_mysql
411 dir=`echo $flag | grep "^-L" | sed s:-L::`
412 if test "x$dir" != 'x'; then
413 if test -f "$dir/libmysqlclient_r.la"; then
414 LDADD_dbd_mysql=$dir/libmysqlclient_r.la
421 APRUTIL_LIBS="$APRUTIL_LIBS $LDADD_dbd_pgsql $LDADD_dbd_sqlite2 $LDADD_dbd_sqlite3 $LDADD_dbd_oracle $LDADD_dbd_mysql $LDADD_dbd_freetds"
422 APRUTIL_EXPORT_LIBS="$APRUTIL_EXPORT_LIBS $LDADD_dbd_pgsql $LDADD_dbd_sqlite2 $LDADD_dbd_sqlite3 $LDADD_dbd_oracle $LDADD_dbd_mysql $LDADD_dbd_freetds"
424 AC_DEFINE([APU_DSO_BUILD], 1, [Define if DBD drivers are built as DSOs])
427 test $apu_have_oracle = 1 && dsos="$dsos dbd/apr_dbd_oracle.la"
428 test $apu_have_pgsql = 1 && dsos="$dsos dbd/apr_dbd_pgsql.la"
429 test $apu_have_mysql = 1 && dsos="$dsos dbd/apr_dbd_mysql.la"
430 test $apu_have_sqlite2 = 1 && dsos="$dsos dbd/apr_dbd_sqlite2.la"
431 test $apu_have_sqlite3 = 1 && dsos="$dsos dbd/apr_dbd_sqlite3.la"
432 test $apu_have_freetds = 1 && dsos="$dsos dbd/apr_dbd_freetds.la"
434 APU_MODULES="$APU_MODULES $dsos"