Document PostgreSQL row counting fix.
[apr-util.git] / build / dbd.m4
blobd3798ff57acbed11e0204344cc4925614a61794a
1 dnl -------------------------------------------------------- -*- autoconf -*-
2 dnl Licensed to the Apache Software Foundation (ASF) under one or more
3 dnl contributor license agreements.  See the NOTICE file distributed with
4 dnl this work for additional information regarding copyright ownership.
5 dnl The ASF licenses this file to You under the Apache License, Version 2.0
6 dnl (the "License"); you may not use this file except in compliance with
7 dnl the License.  You may obtain a copy of the License at
8 dnl
9 dnl     http://www.apache.org/licenses/LICENSE-2.0
10 dnl
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.
17 dnl
18 dnl DBD module
19 dnl
21 dnl
22 dnl APU_CHECK_DBD: compile backends for apr_dbd.
23 dnl
24 AC_DEFUN([APU_CHECK_DBD], [
25   apu_have_pgsql=0
27   old_libs="$LIBS"
28   old_cppflags="$CPPFLAGS"
29   old_ldflags="$LDFLAGS"
31   AC_ARG_WITH([pgsql], APR_HELP_STRING([--with-pgsql=DIR], [specify PostgreSQL location]),
32   [
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`"
38         pgsql_LIBS="`$PGSQL_CONFIG --libs`"
40         APR_ADDTO(CPPFLAGS, [$pgsql_CPPFLAGS])
41         APR_ADDTO(LDFLAGS, [$pgsql_LDFLAGS])
42         APR_ADDTO(LIBS, [$pgsql_LIBS])
43       fi
45       AC_CHECK_HEADERS(libpq-fe.h, AC_CHECK_LIB(pq, PQsendQueryPrepared, [apu_have_pgsql=1]))
46       if test "$apu_have_pgsql" = "0"; then
47         AC_CHECK_HEADERS(postgresql/libpq-fe.h, AC_CHECK_LIB(pq, PQsendQueryPrepared, [apu_have_pgsql=1]))
48       fi
49       if test "$apu_have_pgsql" != "0" && test "x$PGSQL_CONFIG" != 'x'; then
50         APR_ADDTO(APRUTIL_PRIV_INCLUDES, [$pgsql_CPPFLAGS])
51       fi
52     elif test "$withval" = "no"; then
53       :
54     else
55       AC_PATH_PROG([PGSQL_CONFIG],[pg_config],,[$withval/bin])
56       if test "x$PGSQL_CONFIG" != 'x'; then
57         pgsql_CPPFLAGS="-I`$PGSQL_CONFIG --includedir`"
58         pgsql_LDFLAGS="-L`$PGSQL_CONFIG --libdir`"
59         pgsql_LIBS="`$PGSQL_CONFIG --libs`"
60       else
61         pgsql_CPPFLAGS="-I$withval/include"
62         pgsql_LDFLAGS="-L$withval/lib "
63       fi
65       APR_ADDTO(CPPFLAGS, [$pgsql_CPPFLAGS])
66       APR_ADDTO(LDFLAGS, [$pgsql_LDFLAGS])
67       APR_ADDTO(LIBS, [$pgsql_LIBS])
69       AC_MSG_NOTICE(checking for pgsql in $withval)
70       AC_CHECK_HEADERS(libpq-fe.h, AC_CHECK_LIB(pq, PQsendQueryPrepared, [apu_have_pgsql=1]))
71       if test "$apu_have_pgsql" != "1"; then
72         AC_CHECK_HEADERS(postgresql/libpq-fe.h, AC_CHECK_LIB(pq, PQsendQueryPrepared, [apu_have_pgsql=1]))
73       fi
74       if test "$apu_have_pgsql" != "0"; then
75         APR_ADDTO(APRUTIL_PRIV_INCLUDES, [$pgsql_CPPFLAGS])
76       fi
77     fi
78   ], [
79     AC_PATH_PROG([PGSQL_CONFIG],[pg_config])
80     if test "x$PGSQL_CONFIG" != 'x'; then
81       pgsql_CPPFLAGS="-I`$PGSQL_CONFIG --includedir`"
82       pgsql_LDFLAGS="-L`$PGSQL_CONFIG --libdir`"
83       pgsql_LIBS="`$PGSQL_CONFIG --libs`"
85       APR_ADDTO(CPPFLAGS, [$pgsql_CPPFLAGS])
86       APR_ADDTO(LDFLAGS, [$pgsql_LDFLAGS])
87       APR_ADDTO(LIBS, [$pgsql_LIBS])
88     fi
90     AC_CHECK_HEADERS(libpq-fe.h, AC_CHECK_LIB(pq, PQsendQueryPrepared, [apu_have_pgsql=1]))
91     if test "$apu_have_pgsql" = "0"; then
92       AC_CHECK_HEADERS(postgresql/libpq-fe.h, AC_CHECK_LIB(pq, PQsendQueryPrepared, [apu_have_pgsql=1]))
93     fi
94     if test "$apu_have_pgsql" != "0" && test "x$PGSQL_CONFIG" != 'x'; then
95       APR_ADDTO(APRUTIL_PRIV_INCLUDES, [$pgsql_CPPFLAGS])
96     fi
97   ])
98   AC_SUBST(apu_have_pgsql)
99   dnl Since we have already done the AC_CHECK_LIB tests, if we have it, 
100   dnl we know the library is there.
101   if test "$apu_have_pgsql" = "1"; then
102     LDADD_dbd_pgsql="$pgsql_LDFLAGS -lpq $pgsql_LIBS"
103   fi
104   AC_SUBST(LDADD_dbd_pgsql)
106   LIBS="$old_libs"
107   CPPFLAGS="$old_cppflags"
108   LDFLAGS="$old_ldflags"
111 AC_DEFUN([APU_CHECK_DBD_MYSQL], [
112   apu_have_mysql=0
114   old_libs="$LIBS"
115   old_cppflags="$CPPFLAGS"
116   old_ldflags="$LDFLAGS"
118   AC_ARG_WITH([mysql], APR_HELP_STRING([--with-mysql=DIR], [enable MySQL DBD driver]),
119   [
120     if test "$withval" = "yes"; then
121       AC_PATH_PROG([MYSQL_CONFIG],[mysql_config])
122       if test "x$MYSQL_CONFIG" != 'x'; then
123         mysql_CPPFLAGS="`$MYSQL_CONFIG --include`"
124         mysql_LDFLAGS="`$MYSQL_CONFIG --libs_r | sed -e 's/-l[[^ ]]\+//g'`"
125         mysql_LIBS="`$MYSQL_CONFIG --libs_r`"
127         APR_ADDTO(CPPFLAGS, [$mysql_CPPFLAGS])
128         APR_ADDTO(LIBS, [$mysql_LIBS])
129       fi
131       AC_CHECK_HEADERS(mysql.h, AC_CHECK_LIB(mysqlclient_r, mysql_init, [apu_have_mysql=1]))
132       if test "$apu_have_mysql" = "0"; then
133         AC_CHECK_HEADERS(mysql/mysql.h, AC_CHECK_LIB(mysqlclient_r, mysql_init, [apu_have_mysql=1]))
134       fi
135       if test "$apu_have_mysql" != "0" && test "x$MYSQL_CONFIG" != 'x'; then
136         APR_ADDTO(APRUTIL_PRIV_INCLUDES, [$mysql_CPPFLAGS])
137       fi
138     elif test "$withval" = "no"; then
139       :
140     else
141       AC_PATH_PROG([MYSQL_CONFIG],[mysql_config],,[$withval/bin])
142       if test "x$MYSQL_CONFIG" != 'x'; then
143         mysql_CPPFLAGS="`$MYSQL_CONFIG --include`"
144         mysql_LDFLAGS="`$MYSQL_CONFIG --libs_r | sed -e 's/-l[[^ ]]\+//g'`"
145         mysql_LIBS="`$MYSQL_CONFIG --libs_r`"
146       else
147         mysql_CPPFLAGS="-I$withval/include"
148         mysql_LDFLAGS="-L$withval/lib "
149       fi
151       APR_ADDTO(CPPFLAGS, [$mysql_CPPFLAGS])
152       APR_ADDTO(LDFLAGS, [$mysql_LDFLAGS])
153       APR_ADDTO(LIBS, [$mysql_LIBS])
155       AC_MSG_NOTICE(checking for mysql in $withval)
156       AC_CHECK_HEADERS(mysql.h, AC_CHECK_LIB(mysqlclient_r, mysql_init, [apu_have_mysql=1]))
158       if test "$apu_have_mysql" != "1"; then
159         AC_CHECK_HEADERS(mysql/mysql.h, AC_CHECK_LIB(mysqlclient_r, mysql_init, [apu_have_mysql=1]))
160       fi
161       if test "$apu_have_mysql" != "0"; then
162         APR_ADDTO(APRUTIL_PRIV_INCLUDES, [$mysql_CPPFLAGS])
163       fi
164     fi
165   ])
167   AC_SUBST(apu_have_mysql)
169   dnl Since we have already done the AC_CHECK_LIB tests, if we have it, 
170   dnl we know the library is there.
171   if test "$apu_have_mysql" = "1"; then
172     LDADD_dbd_mysql="$mysql_LDFLAGS -lmysqlclient_r $mysql_LIBS"
173   fi
174   AC_SUBST(LDADD_dbd_mysql)
176   LIBS="$old_libs"
177   CPPFLAGS="$old_cppflags"
178   LDFLAGS="$old_ldflags"
181 AC_DEFUN([APU_CHECK_DBD_SQLITE3], [
182   apu_have_sqlite3=0
184   old_libs="$LIBS"
185   old_cppflags="$CPPFLAGS"
186   old_ldflags="$LDFLAGS"
188   AC_ARG_WITH([sqlite3], APR_HELP_STRING([--with-sqlite3=DIR], [enable sqlite3 DBD driver]),
189   [
190     if test "$withval" = "yes"; then
191       AC_CHECK_HEADERS(sqlite3.h, AC_CHECK_LIB(sqlite3, sqlite3_open, [apu_have_sqlite3=1]))
192     elif test "$withval" = "no"; then
193       :
194     else
195       sqlite3_CPPFLAGS="-I$withval/include"
196       sqlite3_LDFLAGS="-L$withval/lib "
198       APR_ADDTO(CPPFLAGS, [$sqlite3_CPPFLAGS])
199       APR_ADDTO(LDFLAGS, [$sqlite3_LDFLAGS])
201       AC_MSG_NOTICE(checking for sqlite3 in $withval)
202       AC_CHECK_HEADERS(sqlite3.h, AC_CHECK_LIB(sqlite3, sqlite3_open, [apu_have_sqlite3=1]))
203       if test "$apu_have_sqlite3" != "0"; then
204         APR_ADDTO(APRUTIL_PRIV_INCLUDES, [-I$withval/include])
205       fi
206     fi
207   ], [
208     AC_CHECK_HEADERS(sqlite3.h, AC_CHECK_LIB(sqlite3, sqlite3_open, [apu_have_sqlite3=1]))
209   ])
211   AC_SUBST(apu_have_sqlite3)
213   dnl Since we have already done the AC_CHECK_LIB tests, if we have it, 
214   dnl we know the library is there.
215   if test "$apu_have_sqlite3" = "1"; then
216     LDADD_dbd_sqlite3="$sqlite3_LDFLAGS -lsqlite3"
217   fi
218   AC_SUBST(LDADD_dbd_sqlite3)
220   LIBS="$old_libs"
221   CPPFLAGS="$old_cppflags"
222   LDFLAGS="$old_ldflags"
225 AC_DEFUN([APU_CHECK_DBD_SQLITE2], [
226   apu_have_sqlite2=0
228   old_libs="$LIBS"
229   old_cppflags="$CPPFLAGS"
230   old_ldflags="$LDFLAGS"
232   AC_ARG_WITH([sqlite2], APR_HELP_STRING([--with-sqlite2=DIR], [enable sqlite2 DBD driver]),
233   [
234     if test "$withval" = "yes"; then
235       AC_CHECK_HEADERS(sqlite.h, AC_CHECK_LIB(sqlite, sqlite_open, [apu_have_sqlite2=1]))
236     elif test "$withval" = "no"; then
237       :
238     else
239       sqlite2_CPPFLAGS="-I$withval/include"
240       sqlite2_LDFLAGS="-L$withval/lib "
242       APR_ADDTO(CPPFLAGS, [$sqlite2_CPPFLAGS])
243       APR_ADDTO(LDFLAGS, [$sqlite2_LDFLAGS])
245       AC_MSG_NOTICE(checking for sqlite2 in $withval)
246       AC_CHECK_HEADERS(sqlite.h, AC_CHECK_LIB(sqlite, sqlite_open, [apu_have_sqlite2=1]))
247       if test "$apu_have_sqlite2" != "0"; then
248         APR_ADDTO(APRUTIL_PRIV_INCLUDES, [-I$withval/include])
249       fi
250     fi
251   ], [
252     AC_CHECK_HEADERS(sqlite.h, AC_CHECK_LIB(sqlite, sqlite_open, [apu_have_sqlite2=1]))
253   ])
255   AC_SUBST(apu_have_sqlite2)
257   dnl Since we have already done the AC_CHECK_LIB tests, if we have it, 
258   dnl we know the library is there.
259   if test "$apu_have_sqlite2" = "1"; then
260     LDADD_dbd_sqlite2="$sqlite2_LDFLAGS -lsqlite"
261   fi
262   AC_SUBST(LDADD_dbd_sqlite2)
264   LIBS="$old_libs"
265   CPPFLAGS="$old_cppflags"
266   LDFLAGS="$old_ldflags"
269 AC_DEFUN([APU_CHECK_DBD_ORACLE], [
270   apu_have_oracle=0
272   old_libs="$LIBS"
273   old_cppflags="$CPPFLAGS"
274   old_ldflags="$LDFLAGS"
276   AC_ARG_WITH([oracle-include],
277     APR_HELP_STRING([--with-oracle-include=DIR], [path to Oracle include files]))
278   AC_ARG_WITH([oracle], 
279     APR_HELP_STRING([--with-oracle=DIR], [enable Oracle DBD driver; giving ORACLE_HOME as DIR]),
280   [
281     if test "$withval" = "yes"; then
282       if test -n "$with_oracle_include"; then
283         oracle_CPPFLAGS="$CPPFLAGS -I$with_oracle_include"
284         APR_ADDTO(APRUTIL_PRIV_INCLUDES, [-I$with_oracle_include])
285       fi
287       APR_ADDTO(CPPFLAGS, [$oracle_CPPFLAGS])
289       AC_CHECK_HEADERS(oci.h, AC_CHECK_LIB(clntsh, OCIEnvCreate, [apu_have_oracle=1],[
290         unset ac_cv_lib_clntsh_OCIEnvCreate
291         oracle_LIBS="-lnnz10"
292         APR_ADDTO(LIBS, [$oracle_LIBS])
293         AC_CHECK_LIB(clntsh, OCIEnvCreate, [apu_have_oracle=1])
294       ]))
295     elif test "$withval" = "no"; then
296       :
297     else
298       if test -n "$with_oracle_include"; then
299         oracle_CPPFLAGS="$CPPFLAGS -I$with_oracle_include"
300         APR_ADDTO(APRUTIL_PRIV_INCLUDES, [-I$with_oracle_include])
301       else
302         oracle_CPPFLAGS="-I$withval/rdbms/demo -I$withval/rdbms/public"
303       fi
304       oracle_LDFLAGS="-L$withval/lib "
306       APR_ADDTO(CPPFLAGS, [$oracle_CPPFLAGS])
307       APR_ADDTO(LDFLAGS, [$oracle_LDFLAGS])
309       AC_MSG_NOTICE(checking for oracle in $withval)
310       AC_CHECK_HEADERS(oci.h, AC_CHECK_LIB(clntsh, OCIEnvCreate, [apu_have_oracle=1],[
311         unset ac_cv_lib_clntsh_OCIEnvCreate
312         oracle_LIBS="-lnnz10"
313         APR_ADDTO(LIBS, [$oracle_LIBS])
314         AC_CHECK_LIB(clntsh, OCIEnvCreate, [apu_have_oracle=1])
315       ]))
316       if test "$apu_have_oracle" != "0"; then
317         oracle_LDFLAGS="$oracle_LDFLAGS -R$withval/lib"
318         if test -z "$with_oracle_include"; then
319           APR_ADDTO(APRUTIL_PRIV_INCLUDES, [-I$withval/rdbms/demo])
320           APR_ADDTO(APRUTIL_PRIV_INCLUDES, [-I$withval/rdbms/public])
321         fi
322       fi
323     fi
324   ])
326   AC_SUBST(apu_have_oracle)
328   dnl Since we have already done the AC_CHECK_LIB tests, if we have it, 
329   dnl we know the library is there.
330   if test "$apu_have_oracle" = "1"; then
331     LDADD_dbd_oracle="$oracle_LDFLAGS -lclntsh $oracle_LIBS"
332   fi
333   AC_SUBST(LDADD_dbd_oracle)
335   LIBS="$old_libs"
336   CPPFLAGS="$old_cppflags"
337   LDFLAGS="$old_ldflags"
341 AC_DEFUN([APU_CHECK_DBD_FREETDS], [
342   apu_have_freetds=0
344   old_libs="$LIBS"
345   old_cppflags="$CPPFLAGS"
346   old_ldflags="$LDFLAGS"
348   AC_ARG_WITH([freetds], 
349     APR_HELP_STRING([--with-freetds=DIR], [specify FreeTDS location]),
350   [
351     if test "$withval" = "yes"; then
352       AC_CHECK_HEADERS(sybdb.h, AC_CHECK_LIB(sybdb, tdsdbopen, [apu_have_freetds=1]))
353     elif test "$withval" = "no"; then
354       :
355     else
356       sybdb_CPPFLAGS="-I$withval/include"
357       sybdb_LDFLAGS="-L$withval/lib "
359       APR_ADDTO(CPPFLAGS, [$sybdb_CPPFLAGS])
360       APR_ADDTO(LDFLAGS, [$sybdb_LDFLAGS])
362       AC_MSG_NOTICE(checking for freetds in $withval)
363       AC_CHECK_HEADERS(sybdb.h, AC_CHECK_LIB(sybdb, tdsdbopen, [apu_have_freetds=1]))
364       if test "$apu_have_freetds" != "0"; then
365         APR_ADDTO(APRUTIL_PRIV_INCLUDES, [-I$withval/include])
366       fi
367     fi
368   ], [
369     AC_CHECK_HEADERS(sybdb.h, AC_CHECK_LIB(sybdb, tdsdbopen, [apu_have_freetds=1]))
370   ])
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="$sybdb_LDFLAGS -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"
381   fi
382   AC_SUBST(LDADD_dbd_freetds)
384   LIBS="$old_libs"
385   CPPFLAGS="$old_cppflags"
386   LDFLAGS="$old_ldflags"
390 AC_DEFUN([APU_CHECK_DBD_ODBC], [
391   apu_have_odbc=0
393   old_libs="$LIBS"
394   old_cppflags="$CPPFLAGS"
395   old_ldflags="$LDFLAGS"
397   AC_ARG_WITH([odbc], APR_HELP_STRING([--with-odbc=DIR], [specify ODBC location]),
398   [
399     if test "$withval" = "yes"; then
400       AC_PATH_PROG([ODBC_CONFIG],[odbc_config])
401       if test "x$ODBC_CONFIG" != 'x'; then
402         odbc_CPPFLAGS="-I`$ODBC_CONFIG --include-prefix`"
403         odbc_LDFLAGS="-L`$ODBC_CONFIG --lib-prefix`"
404         odbc_LIBS="`$ODBC_CONFIG --libs`"
406         APR_ADDTO(CPPFLAGS, [$odbc_CPPFLAGS])
407         APR_ADDTO(LDFLAGS, [$odbc_LDFLAGS])
408         APR_ADDTO(LIBS, [$odbc_LIBS])
409       fi
411       AC_CHECK_HEADERS(sql.h, AC_CHECK_LIB(odbc, SQLAllocHandle, [apu_have_odbc=1]))
412       if test "$apu_have_odbc" = "0"; then
413         AC_CHECK_HEADERS(odbc/sql.h, AC_CHECK_LIB(odbc, SQLAllocHandle, [apu_have_odbc=1]))
414       fi
415       if test "$apu_have_odbc" != "0" && test "x$ODBC_CONFIG" != 'x'; then
416         APR_ADDTO(APRUTIL_PRIV_INCLUDES, [$odbc_CPPFLAGS])
417       fi
418     elif test "$withval" = "no"; then
419       :
420     else
421       AC_PATH_PROG([ODBC_CONFIG],[odbc_config],,[$withval/bin])
422       if test "x$ODBC_CONFIG" != 'x'; then
423         odbc_CPPFLAGS="-I`$ODBC_CONFIG --include-prefix`"
424         odbc_LDFLAGS="-L`$ODBC_CONFIG --lib-prefix`"
425         odbc_LIBS="`$ODBC_CONFIG --libs`"
426       else
427         odbc_CPPFLAGS="-I$withval/include"
428         odbc_LDFLAGS="-L$withval/lib "
429       fi
431       APR_ADDTO(CPPFLAGS, [$odbc_CPPFLAGS])
432       APR_ADDTO(LDFLAGS, [$odbc_LDFLAGS])
433       APR_ADDTO(LIBS, [$odbc_LIBS])
435       AC_MSG_NOTICE(checking for odbc in $withval)
436       AC_CHECK_HEADERS(sql.h, AC_CHECK_LIB(odbc, SQLAllocHandle, [apu_have_odbc=1]))
437       if test "$apu_have_odbc" = "0"; then
438         AC_CHECK_HEADERS(odbc/sql.h, AC_CHECK_LIB(odbc, SQLAllocHandle, [apu_have_odbc=1]))
439       fi
440       if test "$apu_have_odbc" != "0" && test "x$ODBC_CONFIG" != 'x'; then
441         APR_ADDTO(APRUTIL_PRIV_INCLUDES, [$odbc_CPPFLAGS])
442       fi
443     fi
444   ], [
445     AC_PATH_PROG([ODBC_CONFIG],[odbc_config])
446     if test "x$ODBC_CONFIG" != 'x'; then
447       odbc_CPPFLAGS="-I`$ODBC_CONFIG --include-prefix`"
448       odbc_LDFLAGS="-L`$ODBC_CONFIG --lib-prefix`"
449       odbc_LIBS="`$ODBC_CONFIG --libs`"
451       APR_ADDTO(CPPFLAGS, [$odbc_CPPFLAGS])
452       APR_ADDTO(LDFLAGS, [$odbc_LDFLAGS])
453       APR_ADDTO(LIBS, [$odbc_LIBS])
454     fi
456     AC_CHECK_HEADERS(sql.h, AC_CHECK_LIB(odbc, SQLAllocHandle, [apu_have_odbc=1]))
457     if test "$apu_have_odbc" = "0"; then
458       AC_CHECK_HEADERS(odbc/sql.h, AC_CHECK_LIB(odbc, SQLAllocHandle, [apu_have_odbc=1]))
459     fi
460     if test "$apu_have_odbc" != "0" && test "x$ODBC_CONFIG" != 'x'; then
461       APR_ADDTO(APRUTIL_PRIV_INCLUDES, [$odbc_CPPFLAGS])
462     fi
463   ])
464   AC_SUBST(apu_have_odbc)
465   dnl Since we have already done the AC_CHECK_LIB tests, if we have it, 
466   dnl we know the library is there.
467   if test "$apu_have_odbc" = "1"; then
468     LDADD_dbd_odbc="$odbc_LDFLAGS -lodbc $odbc_LIBS"
469   fi
470   AC_SUBST(LDADD_dbd_odbc)
472   LIBS="$old_libs"
473   CPPFLAGS="$old_cppflags"
474   LDFLAGS="$old_ldflags"