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="-L`$PGSQL_CONFIG --libdir` `$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 if test "$apu_have_pgsql" != "0" && test "x$PGSQL_CONFIG" != 'x'; then
48 APR_ADDTO(APRUTIL_PRIV_INCLUDES, [$pgsql_CPPFLAGS])
50 elif test "$withval" = "no"; then
53 AC_PATH_PROG([PGSQL_CONFIG],[pg_config],,[$withval/bin])
54 if test "x$PGSQL_CONFIG" != 'x'; then
55 pgsql_CPPFLAGS="-I`$PGSQL_CONFIG --includedir`"
56 pgsql_LDFLAGS="-L`$PGSQL_CONFIG --libdir` `$PGSQL_CONFIG --libs`"
58 pgsql_CPPFLAGS="-I$withval/include"
59 pgsql_LDFLAGS="-L$withval/lib "
62 APR_ADDTO(CPPFLAGS, [$pgsql_CPPFLAGS])
63 APR_ADDTO(LDFLAGS, [$pgsql_LDFLAGS])
65 AC_MSG_NOTICE(checking for pgsql in $withval)
66 AC_CHECK_HEADERS(libpq-fe.h, AC_CHECK_LIB(pq, PQsendQueryPrepared, [apu_have_pgsql=1]))
67 if test "$apu_have_pgsql" != "1"; then
68 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_PRIV_INCLUDES, [$pgsql_CPPFLAGS])
75 AC_PATH_PROG([PGSQL_CONFIG],[pg_config])
76 if test "x$PGSQL_CONFIG" != 'x'; then
77 pgsql_CPPFLAGS="-I`$PGSQL_CONFIG --includedir`"
78 pgsql_LDFLAGS="-L`$PGSQL_CONFIG --libdir` `$PGSQL_CONFIG --libs`"
80 APR_ADDTO(CPPFLAGS, [$pgsql_CPPFLAGS])
81 APR_ADDTO(LDFLAGS, [$pgsql_LDFLAGS])
84 AC_CHECK_HEADERS(libpq-fe.h, AC_CHECK_LIB(pq, PQsendQueryPrepared, [apu_have_pgsql=1]))
85 if test "$apu_have_pgsql" = "0"; then
86 AC_CHECK_HEADERS(postgresql/libpq-fe.h, AC_CHECK_LIB(pq, PQsendQueryPrepared, [apu_have_pgsql=1]))
88 if test "$apu_have_pgsql" != "0" && test "x$PGSQL_CONFIG" != 'x'; then
89 APR_ADDTO(APRUTIL_PRIV_INCLUDES, [$pgsql_CPPFLAGS])
92 AC_SUBST(apu_have_pgsql)
93 dnl Since we have already done the AC_CHECK_LIB tests, if we have it,
94 dnl we know the library is there.
95 if test "$apu_have_pgsql" = "1"; then
96 LDADD_dbd_pgsql="$pgsql_LDFLAGS -lpq"
98 AC_SUBST(LDADD_dbd_pgsql)
101 CPPFLAGS="$old_cppflags"
102 LDFLAGS="$old_ldflags"
105 AC_DEFUN([APU_CHECK_DBD_MYSQL], [
109 old_cppflags="$CPPFLAGS"
110 old_ldflags="$LDFLAGS"
112 AC_ARG_WITH([mysql], APR_HELP_STRING([--with-mysql=DIR], [enable MySQL DBD driver]),
114 if test "$withval" = "yes"; then
115 AC_PATH_PROG([MYSQL_CONFIG],[mysql_config])
116 if test "x$MYSQL_CONFIG" != 'x'; then
117 mysql_CPPFLAGS="`$MYSQL_CONFIG --include`"
118 mysql_LDFLAGS="`$MYSQL_CONFIG --libs_r`"
120 APR_ADDTO(CPPFLAGS, [$mysql_CPPFLAGS])
121 APR_ADDTO(LDFLAGS, [$mysql_LDFLAGS])
124 AC_CHECK_HEADERS(mysql.h, AC_CHECK_LIB(mysqlclient_r, mysql_init, [apu_have_mysql=1]))
125 if test "$apu_have_mysql" = "0"; then
126 AC_CHECK_HEADERS(mysql/mysql.h, AC_CHECK_LIB(mysqlclient_r, mysql_init, [apu_have_mysql=1]))
128 if test "$apu_have_mysql" != "0" && test "x$MYSQL_CONFIG" != 'x'; then
129 APR_ADDTO(APRUTIL_PRIV_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]))
149 if test "$apu_have_mysql" != "1"; then
150 AC_CHECK_HEADERS(mysql/mysql.h, AC_CHECK_LIB(mysqlclient_r, mysql_init, [apu_have_mysql=1]))
152 if test "$apu_have_mysql" != "0"; then
153 APR_ADDTO(APRUTIL_PRIV_INCLUDES, [$mysql_CPPFLAGS])
158 AC_SUBST(apu_have_mysql)
160 dnl Since we have already done the AC_CHECK_LIB tests, if we have it,
161 dnl we know the library is there.
162 if test "$apu_have_mysql" = "1"; then
163 LDADD_dbd_mysql=$mysql_LDFLAGS
165 AC_SUBST(LDADD_dbd_mysql)
168 CPPFLAGS="$old_cppflags"
169 LDFLAGS="$old_ldflags"
172 AC_DEFUN([APU_CHECK_DBD_SQLITE3], [
176 old_cppflags="$CPPFLAGS"
177 old_ldflags="$LDFLAGS"
179 AC_ARG_WITH([sqlite3], APR_HELP_STRING([--with-sqlite3=DIR], [enable sqlite3 DBD driver]),
181 if test "$withval" = "yes"; then
182 AC_CHECK_HEADERS(sqlite3.h, AC_CHECK_LIB(sqlite3, sqlite3_open, [apu_have_sqlite3=1]))
183 elif test "$withval" = "no"; then
186 sqlite3_CPPFLAGS="-I$withval/include"
187 sqlite3_LDFLAGS="-L$withval/lib "
189 APR_ADDTO(CPPFLAGS, [$sqlite3_CPPFLAGS])
190 APR_ADDTO(LDFLAGS, [$sqlite3_LDFLAGS])
192 AC_MSG_NOTICE(checking for sqlite3 in $withval)
193 AC_CHECK_HEADERS(sqlite3.h, AC_CHECK_LIB(sqlite3, sqlite3_open, [apu_have_sqlite3=1]))
194 if test "$apu_have_sqlite3" != "0"; then
195 APR_ADDTO(APRUTIL_PRIV_INCLUDES, [-I$withval/include])
199 AC_CHECK_HEADERS(sqlite3.h, AC_CHECK_LIB(sqlite3, sqlite3_open, [apu_have_sqlite3=1]))
202 AC_SUBST(apu_have_sqlite3)
204 dnl Since we have already done the AC_CHECK_LIB tests, if we have it,
205 dnl we know the library is there.
206 if test "$apu_have_sqlite3" = "1"; then
207 LDADD_dbd_sqlite3="$sqlite3_LDFLAGS -lsqlite3"
209 AC_SUBST(LDADD_dbd_sqlite3)
212 CPPFLAGS="$old_cppflags"
213 LDFLAGS="$old_ldflags"
216 AC_DEFUN([APU_CHECK_DBD_SQLITE2], [
220 old_cppflags="$CPPFLAGS"
221 old_ldflags="$LDFLAGS"
223 AC_ARG_WITH([sqlite2], APR_HELP_STRING([--with-sqlite2=DIR], [enable sqlite2 DBD driver]),
225 if test "$withval" = "yes"; then
226 AC_CHECK_HEADERS(sqlite.h, AC_CHECK_LIB(sqlite, sqlite_open, [apu_have_sqlite2=1]))
227 elif test "$withval" = "no"; then
230 sqlite2_CPPFLAGS="-I$withval/include"
231 sqlite2_LDFLAGS="-L$withval/lib "
233 APR_ADDTO(CPPFLAGS, [$sqlite2_CPPFLAGS])
234 APR_ADDTO(LDFLAGS, [$sqlite2_LDFLAGS])
236 AC_MSG_NOTICE(checking for sqlite2 in $withval)
237 AC_CHECK_HEADERS(sqlite.h, AC_CHECK_LIB(sqlite, sqlite_open, [apu_have_sqlite2=1]))
238 if test "$apu_have_sqlite2" != "0"; then
239 APR_ADDTO(APRUTIL_PRIV_INCLUDES, [-I$withval/include])
243 AC_CHECK_HEADERS(sqlite.h, AC_CHECK_LIB(sqlite, sqlite_open, [apu_have_sqlite2=1]))
246 AC_SUBST(apu_have_sqlite2)
248 dnl Since we have already done the AC_CHECK_LIB tests, if we have it,
249 dnl we know the library is there.
250 if test "$apu_have_sqlite2" = "1"; then
251 LDADD_dbd_sqlite2="$sqlite2_LDFLAGS -lsqlite"
253 AC_SUBST(LDADD_dbd_sqlite2)
256 CPPFLAGS="$old_cppflags"
257 LDFLAGS="$old_ldflags"
260 AC_DEFUN([APU_CHECK_DBD_ORACLE], [
264 old_cppflags="$CPPFLAGS"
265 old_ldflags="$LDFLAGS"
267 AC_ARG_WITH([oracle-include],
268 APR_HELP_STRING([--with-oracle-include=DIR], [path to Oracle include files]))
269 AC_ARG_WITH([oracle],
270 APR_HELP_STRING([--with-oracle=DIR], [enable Oracle DBD driver; giving ORACLE_HOME as DIR]),
272 if test "$withval" = "yes"; then
273 if test -n "$with_oracle_include"; then
274 oracle_CPPFLAGS="$CPPFLAGS -I$with_oracle_include"
275 APR_ADDTO(APRUTIL_PRIV_INCLUDES, [-I$with_oracle_include])
278 APR_ADDTO(CPPFLAGS, [$oracle_CPPFLAGS])
280 AC_CHECK_HEADERS(oci.h, AC_CHECK_LIB(clntsh, OCIEnvCreate, [apu_have_oracle=1],[
281 unset ac_cv_lib_clntsh_OCIEnvCreate
282 AC_CHECK_LIB(clntsh, OCIEnvCreate, [
284 LDADD_dbd_oracle="-lnnz10"
287 elif test "$withval" = "no"; then
290 if test -n "$with_oracle_include"; then
291 oracle_CPPFLAGS="$CPPFLAGS -I$with_oracle_include"
292 APR_ADDTO(APRUTIL_PRIV_INCLUDES, [-I$with_oracle_include])
294 oracle_CPPFLAGS="-I$withval/rdbms/demo -I$withval/rdbms/public"
296 oracle_LDFLAGS="-L$withval/lib "
298 APR_ADDTO(CPPFLAGS, [$oracle_CPPFLAGS])
299 APR_ADDTO(LDFLAGS, [$oracle_LDFLAGS])
301 AC_MSG_NOTICE(checking for oracle in $withval)
302 AC_CHECK_HEADERS(oci.h, AC_CHECK_LIB(clntsh, OCIEnvCreate, [apu_have_oracle=1],[
303 unset ac_cv_lib_clntsh_OCIEnvCreate
304 AC_CHECK_LIB(clntsh, OCIEnvCreate, [
306 LDADD_dbd_oracle="-lnnz10"
309 if test "$apu_have_oracle" != "0"; then
310 LDADD_dbd_oracle="-R$withval/lib"
311 if test -z "$with_oracle_include"; then
312 APR_ADDTO(APRUTIL_PRIV_INCLUDES, [-I$withval/rdbms/demo])
313 APR_ADDTO(APRUTIL_PRIV_INCLUDES, [-I$withval/rdbms/public])
319 AC_SUBST(apu_have_oracle)
321 dnl Since we have already done the AC_CHECK_LIB tests, if we have it,
322 dnl we know the library is there.
323 if test "$apu_have_oracle" = "1"; then
324 LDADD_dbd_oracle="$oracle_LDFLAGS $LDADD_dbd_oracle -lclntsh"
326 AC_SUBST(LDADD_dbd_oracle)
329 CPPFLAGS="$old_cppflags"
330 LDFLAGS="$old_ldflags"
334 AC_DEFUN([APU_CHECK_DBD_FREETDS], [
338 old_cppflags="$CPPFLAGS"
339 old_ldflags="$LDFLAGS"
341 AC_ARG_WITH([freetds],
342 APR_HELP_STRING([--with-freetds=DIR], [specify FreeTDS location]),
344 if test "$withval" = "yes"; then
345 AC_CHECK_HEADERS(sybdb.h, AC_CHECK_LIB(sybdb, tdsdbopen, [apu_have_freetds=1]))
346 elif test "$withval" = "no"; then
349 sybdb_CPPFLAGS="-I$withval/include"
350 sybdb_LDFLAGS="-L$withval/lib "
352 APR_ADDTO(CPPFLAGS, [$sybdb_CPPFLAGS])
353 APR_ADDTO(LDFLAGS, [$sybdb_LDFLAGS])
355 AC_MSG_NOTICE(checking for freetds in $withval)
356 AC_CHECK_HEADERS(sybdb.h, AC_CHECK_LIB(sybdb, tdsdbopen, [apu_have_freetds=1]))
357 if test "$apu_have_freetds" != "0"; then
358 APR_ADDTO(APRUTIL_PRIV_INCLUDES, [-I$withval/include])
362 AC_CHECK_HEADERS(sybdb.h, AC_CHECK_LIB(sybdb, tdsdbopen, [apu_have_freetds=1]))
365 AC_SUBST(apu_have_freetds)
367 dnl Since we have already done the AC_CHECK_LIB tests, if we have it,
368 dnl we know the library is there.
369 if test "$apu_have_freetds" = "1"; then
370 LDADD_dbd_freetds="$sybdb_LDFLAGS -lsybdb"
371 dnl Erm, I needed pcreposix, but I think that dependency has gone
372 dnl from the current code
373 dnl LDADD_dbd_freetds="$LDADD_dbd_freetds -lsybdb -lpcreposix"
375 AC_SUBST(LDADD_dbd_freetds)
378 CPPFLAGS="$old_cppflags"
379 LDFLAGS="$old_ldflags"
383 AC_DEFUN([APU_CHECK_DBD_DSO], [
385 AC_ARG_ENABLE([dbd-dso],
386 APR_HELP_STRING([--disable-dbd-dso], [disable DSO build of DBD drivers]))
388 if test "$enable_dbd_dso" = "no"; then
389 # Statically link the DBD drivers:
392 test $apu_have_oracle = 1 && objs="$objs dbd/apr_dbd_oracle.lo"
393 test $apu_have_pgsql = 1 && objs="$objs dbd/apr_dbd_pgsql.lo"
394 test $apu_have_mysql = 1 && objs="$objs dbd/apr_dbd_mysql.lo"
395 test $apu_have_sqlite2 = 1 && objs="$objs dbd/apr_dbd_sqlite2.lo"
396 test $apu_have_sqlite3 = 1 && objs="$objs dbd/apr_dbd_sqlite3.lo"
397 test $apu_have_freetds = 1 && objs="$objs dbd/apr_dbd_freetds.lo"
398 EXTRA_OBJECTS="$EXTRA_OBJECTS $objs"
400 # Use libtool *.la for mysql if available
401 if test $apu_have_mysql = 1; then
402 for flag in $LDADD_dbd_mysql
404 dir=`echo $flag | grep "^-L" | sed s:-L::`
405 if test "x$dir" != 'x'; then
406 if test -f "$dir/libmysqlclient_r.la"; then
407 LDADD_dbd_mysql=$dir/libmysqlclient_r.la
414 APRUTIL_LIBS="$APRUTIL_LIBS $LDADD_dbd_pgsql $LDADD_dbd_sqlite2 $LDADD_dbd_sqlite3 $LDADD_dbd_oracle $LDADD_dbd_mysql $LDADD_dbd_freetds"
415 APRUTIL_EXPORT_LIBS="$APRUTIL_EXPORT_LIBS $LDADD_dbd_pgsql $LDADD_dbd_sqlite2 $LDADD_dbd_sqlite3 $LDADD_dbd_oracle $LDADD_dbd_mysql $LDADD_dbd_freetds"
417 AC_DEFINE([APU_DSO_BUILD], 1, [Define if DBD drivers are built as DSOs])
420 test $apu_have_oracle = 1 && dsos="$dsos dbd/apr_dbd_oracle.la"
421 test $apu_have_pgsql = 1 && dsos="$dsos dbd/apr_dbd_pgsql.la"
422 test $apu_have_mysql = 1 && dsos="$dsos dbd/apr_dbd_mysql.la"
423 test $apu_have_sqlite2 = 1 && dsos="$dsos dbd/apr_dbd_sqlite2.la"
424 test $apu_have_sqlite3 = 1 && dsos="$dsos dbd/apr_dbd_sqlite3.la"
425 test $apu_have_freetds = 1 && dsos="$dsos dbd/apr_dbd_freetds.la"
427 APU_MODULES="$APU_MODULES $dsos"