xref: /PHP-7.3/ext/dba/config.m4 (revision 902d39a3)
1dnl config.m4 for extension dba
2
3dnl Suppose we need FlatFile if no support or only CDB is used.
4
5AC_DEFUN([PHP_DBA_STD_BEGIN],[
6  unset THIS_INCLUDE THIS_LIBS THIS_LFLAGS THIS_PREFIX THIS_RESULT
7])
8
9AC_DEFUN([PHP_TEMP_LDFLAGS],[
10  old_LDFLAGS=$LDFLAGS
11  LDFLAGS="$1 $LDFLAGS"
12  old_LIBS=$LIBS
13  LIBS="$2 $LIBS"
14  $3
15  LDFLAGS=$old_LDFLAGS
16  LIBS=$old_LIBS
17])
18
19dnl Assign INCLUDE/LFLAGS from PREFIX
20AC_DEFUN([PHP_DBA_STD_ASSIGN],[
21  if test -n "$THIS_PREFIX" && test "$THIS_PREFIX" != "/usr"; then
22    THIS_LFLAGS=$THIS_PREFIX/$PHP_LIBDIR
23  fi
24])
25
26dnl Standard check
27AC_DEFUN([PHP_DBA_STD_CHECK],[
28  THIS_RESULT=yes
29  if test -z "$THIS_INCLUDE"; then
30    AC_MSG_ERROR([DBA: Could not find necessary header file(s).])
31  fi
32  if test -z "$THIS_LIBS"; then
33    AC_MSG_ERROR([DBA: Could not find necessary library.])
34  fi
35])
36
37dnl Attach THIS_x to DBA_x
38AC_DEFUN([PHP_DBA_STD_ATTACH],[
39  PHP_ADD_LIBRARY_WITH_PATH($THIS_LIBS, $THIS_LFLAGS, DBA_SHARED_LIBADD)
40  unset THIS_INCLUDE THIS_LIBS THIS_LFLAGS THIS_PREFIX
41])
42
43dnl Print the result message
44dnl parameters(name [, full name [, empty or error message]])
45AC_DEFUN([PHP_DBA_STD_RESULT],[
46  THIS_NAME=[]translit($1,a-z0-9-,A-Z0-9_)
47  if test -n "$2"; then
48    THIS_FULL_NAME="$2"
49  else
50    THIS_FULL_NAME="$THIS_NAME"
51  fi
52  AC_MSG_CHECKING([for $THIS_FULL_NAME support])
53  if test -n "$3"; then
54    AC_MSG_ERROR($3)
55  fi
56  if test "$THIS_RESULT" = "yes" || test "$THIS_RESULT" = "builtin"; then
57    HAVE_DBA=1
58    eval HAVE_$THIS_NAME=1
59    AC_MSG_RESULT([$THIS_RESULT])
60  else
61    AC_MSG_RESULT(no)
62  fi
63  unset THIS_RESULT THIS_NAME THIS_FULL_NAME
64])
65
66dnl
67dnl Options
68dnl
69
70PHP_ARG_ENABLE(dba,,
71[  --enable-dba            Build DBA with bundled modules. To build shared DBA
72                          extension use --enable-dba=shared])
73
74PHP_ARG_WITH(qdbm,,
75[  --with-qdbm[=DIR]         DBA: QDBM support], no, no)
76
77PHP_ARG_WITH(gdbm,,
78[  --with-gdbm[=DIR]         DBA: GDBM support], no, no)
79
80PHP_ARG_WITH(ndbm,,
81[  --with-ndbm[=DIR]         DBA: NDBM support], no, no)
82
83PHP_ARG_WITH(db4,,
84[  --with-db4[=DIR]          DBA: Oracle Berkeley DB 4.x or 5.x support], no, no)
85
86PHP_ARG_WITH(db3,,
87[  --with-db3[=DIR]          DBA: Oracle Berkeley DB 3.x support], no, no)
88
89PHP_ARG_WITH(db2,,
90[  --with-db2[=DIR]          DBA: Oracle Berkeley DB 2.x support], no, no)
91
92PHP_ARG_WITH(db1,,
93[  --with-db1[=DIR]          DBA: Oracle Berkeley DB 1.x support/emulation], no, no)
94
95PHP_ARG_WITH(dbm,,
96[  --with-dbm[=DIR]          DBA: DBM support], no, no)
97
98PHP_ARG_WITH(tcadb,,
99[  --with-tcadb[=DIR]        DBA: Tokyo Cabinet abstract DB support], no, no)
100
101PHP_ARG_WITH(lmdb,,
102[  --with-lmdb[=DIR]         DBA: Lightning memory-mapped database support], no, no)
103
104
105dnl
106dnl Library checks
107dnl
108
109# QDBM
110if test "$PHP_QDBM" != "no"; then
111  PHP_DBA_STD_BEGIN
112  for i in $PHP_QDBM /usr/local /usr; do
113    if test -f "$i/include/depot.h"; then
114      THIS_PREFIX=$i
115      THIS_INCLUDE=$i/include/depot.h
116      break
117    fi
118  done
119
120  if test -n "$THIS_INCLUDE"; then
121    for LIB in qdbm; do
122      PHP_CHECK_LIBRARY($LIB, dpopen, [
123        AC_DEFINE_UNQUOTED(QDBM_INCLUDE_FILE, "$THIS_INCLUDE", [ ])
124        AC_DEFINE(DBA_QDBM, 1, [ ])
125        THIS_LIBS=$LIB
126      ], [], [-L$THIS_PREFIX/$PHP_LIBDIR])
127      if test -n "$THIS_LIBS"; then
128        break
129      fi
130    done
131  fi
132
133  PHP_DBA_STD_ASSIGN
134  PHP_DBA_STD_CHECK
135  PHP_DBA_STD_ATTACH
136fi
137PHP_DBA_STD_RESULT(qdbm)
138
139# GDBM
140if test "$PHP_GDBM" != "no"; then
141  PHP_DBA_STD_BEGIN
142  if test "$HAVE_QDBM" = "1"; then
143    PHP_DBA_STD_RESULT(gdbm, gdbm, [You cannot combine --with-gdbm with --with-qdbm])
144  fi
145  for i in $PHP_GDBM /usr/local /usr; do
146    if test -f "$i/include/gdbm.h"; then
147      THIS_PREFIX=$i
148      THIS_INCLUDE=$i/include/gdbm.h
149      break
150    fi
151  done
152
153  if test -n "$THIS_INCLUDE"; then
154    PHP_CHECK_LIBRARY(gdbm, gdbm_open, [
155      AC_DEFINE_UNQUOTED(GDBM_INCLUDE_FILE, "$THIS_INCLUDE", [ ])
156      AC_DEFINE(DBA_GDBM, 1, [ ])
157      THIS_LIBS=gdbm
158    ], [], [-L$THIS_PREFIX/$PHP_LIBDIR])
159  fi
160
161  PHP_DBA_STD_ASSIGN
162  PHP_DBA_STD_CHECK
163  PHP_DBA_STD_ATTACH
164fi
165PHP_DBA_STD_RESULT(gdbm)
166
167# NDBM
168if test "$PHP_NDBM" != "no"; then
169  PHP_DBA_STD_BEGIN
170  for i in $PHP_NDBM /usr/local /usr; do
171    if test -f "$i/include/ndbm.h"; then
172      THIS_PREFIX=$i
173      THIS_INCLUDE=$i/include/ndbm.h
174      break
175    elif test -f "$i/include/db1/ndbm.h"; then
176      THIS_PREFIX=$i
177      THIS_INCLUDE=$i/include/db1/ndbm.h
178      break
179    fi
180  done
181
182  if test -n "$THIS_INCLUDE"; then
183    for LIB in ndbm db1 c; do
184      PHP_CHECK_LIBRARY($LIB, dbm_open, [
185        AC_DEFINE_UNQUOTED(NDBM_INCLUDE_FILE, "$THIS_INCLUDE", [ ])
186        AC_DEFINE(DBA_NDBM, 1, [ ])
187        THIS_LIBS=$LIB
188      ], [], [-L$THIS_PREFIX/$PHP_LIBDIR])
189      if test -n "$THIS_LIBS"; then
190        break
191      fi
192    done
193  fi
194
195  PHP_DBA_STD_ASSIGN
196  PHP_DBA_STD_CHECK
197  PHP_DBA_STD_ATTACH
198fi
199PHP_DBA_STD_RESULT(ndbm)
200
201dnl TCADB
202if test "$PHP_TCADB" != "no"; then
203  PHP_DBA_STD_BEGIN
204  for i in $PHP_TCADB /usr/local /usr; do
205	if test -f "$i/include/tcadb.h"; then
206	  THIS_PREFIX=$i
207	  PHP_ADD_INCLUDE($THIS_PREFIX/include)
208	  THIS_INCLUDE=$i/include/tcadb.h
209	  break
210	fi
211  done
212
213  if test -n "$THIS_INCLUDE"; then
214	for LIB in tokyocabinet; do
215	  PHP_CHECK_LIBRARY($LIB, tcadbopen, [
216		AC_DEFINE_UNQUOTED(TCADB_INCLUDE_FILE, "$THIS_INCLUDE", [ ])
217		AC_DEFINE(DBA_TCADB, 1, [ ])
218		THIS_LIBS=$LIB
219	  ], [], [-L$THIS_PREFIX/$PHP_LIBDIR])
220	  if test -n "$THIS_LIBS"; then
221		break
222	  fi
223	done
224  fi
225
226  PHP_DBA_STD_ASSIGN
227  PHP_DBA_STD_CHECK
228  PHP_DBA_STD_ATTACH
229fi
230PHP_DBA_STD_RESULT(tcadb)
231
232dnl LMDB
233if test "$PHP_LMDB" != "no"; then
234  PHP_DBA_STD_BEGIN
235  for i in $PHP_LMDB /usr/local /usr; do
236	if test -f "$i/include/lmdb.h"; then
237	  THIS_PREFIX=$i
238	  PHP_ADD_INCLUDE($THIS_PREFIX/include)
239	  THIS_INCLUDE=$i/include/lmdb.h
240	  break
241	fi
242  done
243
244  if test -n "$THIS_INCLUDE"; then
245	for LIB in lmdb; do
246	  PHP_CHECK_LIBRARY($LIB, mdb_env_open, [
247		AC_DEFINE_UNQUOTED(LMDB_INCLUDE_FILE, "$THIS_INCLUDE", [ ])
248		AC_DEFINE(DBA_LMDB, 1, [ ])
249		THIS_LIBS=$LIB
250	  ], [], [-L$THIS_PREFIX/$PHP_LIBDIR])
251	  if test -n "$THIS_LIBS"; then
252		break
253	  fi
254	done
255  fi
256
257  PHP_DBA_STD_ASSIGN
258  PHP_DBA_STD_CHECK
259  PHP_DBA_STD_ATTACH
260fi
261PHP_DBA_STD_RESULT(lmdb)
262
263dnl Berkeley specific (library and version test)
264dnl parameters(version, library list, function)
265AC_DEFUN([PHP_DBA_DB_CHECK],[
266  if test -z "$THIS_INCLUDE"; then
267    AC_MSG_ERROR([DBA: Could not find necessary header file(s).])
268  fi
269  for LIB in $2; do
270    if test -f $THIS_PREFIX/$PHP_LIBDIR/lib$LIB.a || test -f $THIS_PREFIX/$PHP_LIBDIR/lib$LIB.$SHLIB_SUFFIX_NAME; then
271      lib_found="";
272      PHP_TEMP_LDFLAGS(-L$THIS_PREFIX/$PHP_LIBDIR, -l$LIB,[
273        AC_LINK_IFELSE([AC_LANG_PROGRAM([[
274#include "$THIS_INCLUDE"
275        ]],[[
276          $3;
277        ]])],[
278          AC_EGREP_CPP(yes,[
279#include "$THIS_INCLUDE"
280#if DB_VERSION_MAJOR == $1 || ($1 == 4 && DB_VERSION_MAJOR == 5)
281            yes
282#endif
283          ],[
284            THIS_LIBS=$LIB
285            lib_found=1
286          ])
287        ],[])
288      ])
289      if test -n "$lib_found"; then
290        lib_found="";
291        break;
292      fi
293    fi
294  done
295  if test -z "$THIS_LIBS"; then
296    AC_MSG_CHECKING([for DB$1 major version])
297    AC_MSG_ERROR([Header contains different version])
298  fi
299  if test "$1" = "4"; then
300    AC_MSG_CHECKING([for DB4 minor version and patch level])
301    AC_EGREP_CPP(yes,[
302#include "$THIS_INCLUDE"
303#if DB_VERSION_MAJOR > 4 || (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR != 1) || (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR == 1 && DB_VERSION_PATCH >= 25)
304      yes
305#endif
306    ],[
307      AC_MSG_RESULT(ok)
308    ],[
309      AC_MSG_ERROR([Version 4.1 requires patch level 25])
310    ])
311  fi
312  if test "$ext_shared" = "yes"; then
313    AC_MSG_CHECKING([if dba can be used as shared extension])
314    AC_EGREP_CPP(yes,[
315#include "$THIS_INCLUDE"
316#if DB_VERSION_MAJOR > 3 || (DB_VERSION_MAJOR == 3 && DB_VERSION_MINOR > 2)
317      yes
318#endif
319    ],[
320      AC_MSG_RESULT(yes)
321    ],[
322      AC_MSG_ERROR([At least version 3.3 is required])
323    ])
324  fi
325  if test -n "$THIS_LIBS"; then
326    AC_DEFINE(DBA_DB$1, 1, [ ])
327    if test -n "$THIS_INCLUDE"; then
328      AC_DEFINE_UNQUOTED(DB$1_INCLUDE_FILE, "$THIS_INCLUDE", [ ])
329    fi
330  else
331    AC_MSG_ERROR([DBA: Could not find necessary library.])
332  fi
333  THIS_RESULT=yes
334  DB$1_LIBS=$THIS_LIBS
335  DB$1_PREFIX=$THIS_PREFIX
336  DB$1_INCLUDE=$THIS_INCLUDE
337  PHP_DBA_STD_ASSIGN
338  PHP_DBA_STD_ATTACH
339])
340
341# DB4
342if test "$PHP_DB4" != "no"; then
343  PHP_DBA_STD_BEGIN
344  dbdp4="/usr/local/BerkeleyDB.4."
345  dbdp5="/usr/local/BerkeleyDB.5."
346  for i in $PHP_DB4 ${dbdp5}1 ${dbdp5}0 ${dbdp4}8 ${dbdp4}7 ${dbdp4}6 ${dbdp4}5 ${dbdp4}4 ${dbdp4}3 ${dbdp4}2 ${dbdp4}1 ${dbdp}0 /usr/local /usr; do
347    if test -f "$i/db5/db.h"; then
348      THIS_PREFIX=$i
349      THIS_INCLUDE=$i/db5/db.h
350      break
351    elif test -f "$i/db4/db.h"; then
352      THIS_PREFIX=$i
353      THIS_INCLUDE=$i/db4/db.h
354      break
355    elif test -f "$i/include/db5.3/db.h"; then
356      THIS_PREFIX=$i
357      THIS_INCLUDE=$i/include/db5.3/db.h
358      break
359    elif test -f "$i/include/db5.1/db.h"; then
360      THIS_PREFIX=$i
361      THIS_INCLUDE=$i/include/db5.1/db.h
362      break
363    elif test -f "$i/include/db5.0/db.h"; then
364      THIS_PREFIX=$i
365      THIS_INCLUDE=$i/include/db5.0/db.h
366      break
367    elif test -f "$i/include/db4.8/db.h"; then
368      THIS_PREFIX=$i
369      THIS_INCLUDE=$i/include/db4.8/db.h
370      break
371    elif test -f "$i/include/db4.7/db.h"; then
372      THIS_PREFIX=$i
373      THIS_INCLUDE=$i/include/db4.7/db.h
374      break
375    elif test -f "$i/include/db4.6/db.h"; then
376      THIS_PREFIX=$i
377      THIS_INCLUDE=$i/include/db4.6/db.h
378      break
379    elif test -f "$i/include/db4.5/db.h"; then
380      THIS_PREFIX=$i
381      THIS_INCLUDE=$i/include/db4.5/db.h
382      break
383    elif test -f "$i/include/db4/db.h"; then
384      THIS_PREFIX=$i
385      THIS_INCLUDE=$i/include/db4/db.h
386      break
387    elif test -f "$i/include/db/db4.h"; then
388      THIS_PREFIX=$i
389      THIS_INCLUDE=$i/include/db/db4.h
390      break
391    elif test -f "$i/include/db4.h"; then
392      THIS_PREFIX=$i
393      THIS_INCLUDE=$i/include/db4.h
394      break
395    elif test -f "$i/include/db.h"; then
396      THIS_PREFIX=$i
397      THIS_INCLUDE=$i/include/db.h
398      break
399    fi
400  done
401  PHP_DBA_DB_CHECK(4, db-5.3 db-5.1 db-5.0 db-4.8 db-4.7 db-4.6 db-4.5 db-4.4 db-4.3 db-4.2 db-4.1 db-4.0 db-4 db4 db, [(void)db_create((DB**)0, (DB_ENV*)0, 0)])
402fi
403PHP_DBA_STD_RESULT(db4,Berkeley DB4)
404
405# DB3
406if test "$PHP_DB3" != "no"; then
407  PHP_DBA_STD_BEGIN
408  if test "$HAVE_DB4" = "1"; then
409    PHP_DBA_STD_RESULT(db3, Berkeley DB3, [You cannot combine --with-db3 with --with-db4])
410  fi
411  for i in $PHP_DB3 /usr/local/BerkeleyDB.3.3 /usr/local/BerkeleyDB.3.2 /usr/local/BerkeleyDB.3.1 /usr/local/BerkeleyDB.3.0 /usr/local /usr; do
412    if test -f "$i/db3/db.h"; then
413      THIS_PREFIX=$i
414      THIS_INCLUDE=$i/include/db3/db.h
415      break
416    elif test -f "$i/include/db3/db.h"; then
417      THIS_PREFIX=$i
418      THIS_INCLUDE=$i/include/db3/db.h
419      break
420    elif test -f "$i/include/db/db3.h"; then
421      THIS_PREFIX=$i
422      THIS_INCLUDE=$i/include/db/db3.h
423      break
424    elif test -f "$i/include/db3.h"; then
425      THIS_PREFIX=$i
426      THIS_INCLUDE=$i/include/db3.h
427      break
428    elif test -f "$i/include/db.h"; then
429      THIS_PREFIX=$i
430      THIS_INCLUDE=$i/include/db.h
431      break
432    fi
433  done
434  PHP_DBA_DB_CHECK(3, db-3.3 db-3.2 db-3.1 db-3.0 db-3 db3 db, [(void)db_create((DB**)0, (DB_ENV*)0, 0)])
435fi
436PHP_DBA_STD_RESULT(db3,Berkeley DB3)
437
438# DB2
439if test "$PHP_DB2" != "no"; then
440  PHP_DBA_STD_BEGIN
441  if test "$HAVE_DB3" = "1" || test "$HAVE_DB4" = "1"; then
442    PHP_DBA_STD_RESULT(db2, Berkeley DB2, [You cannot combine --with-db2 with --with-db3 or --with-db4])
443  fi
444  for i in $PHP_DB2 $PHP_DB2/BerkeleyDB /usr/BerkeleyDB /usr/local /usr; do
445    if test -f "$i/db2/db.h"; then
446      THIS_PREFIX=$i
447      THIS_INCLUDE=$i/db2/db.h
448      break
449    elif test -f "$i/include/db2/db.h"; then
450      THIS_PREFIX=$i
451      THIS_INCLUDE=$i/include/db2/db.h
452      break
453    elif test -f "$i/include/db/db2.h"; then
454      THIS_PREFIX=$i
455      THIS_INCLUDE=$i/include/db/db2.h
456      break
457    elif test -f "$i/include/db2.h"; then
458      THIS_PREFIX=$i
459      THIS_INCLUDE=$i/include/db2.h
460      break
461    elif test -f "$i/include/db.h"; then
462      THIS_PREFIX=$i
463      THIS_INCLUDE=$i/include/db.h
464      break
465    fi
466  done
467  PHP_DBA_DB_CHECK(2, db-2 db2 db,  [(void)db_appinit("", NULL, (DB_ENV*)0, 0)])
468fi
469PHP_DBA_STD_RESULT(db2, Berkeley DB2)
470
471# DB1
472if test "$PHP_DB1" != "no"; then
473  PHP_DBA_STD_BEGIN
474  AC_MSG_CHECKING([for DB1 in library])
475  if test "$HAVE_DB4" = "1"; then
476    THIS_VERSION=4
477    THIS_LIBS=$DB4_LIBS
478    THIS_PREFIX=$DB4_PREFIX
479  elif test "$HAVE_DB3" = "1"; then
480    THIS_LIBS=$DB3_LIBS
481    THIS_PREFIX=$DB3_PREFIX
482  elif test "$HAVE_DB2" = "1"; then
483    THIS_VERSION=2
484    THIS_LIBS=$DB2_LIBS
485    THIS_PREFIX=$DB2_PREFIX
486  fi
487  if test "$HAVE_DB4" = "1" || test "$HAVE_DB3" = "1" || test "$HAVE_DB2" = "1"; then
488    AC_DEFINE_UNQUOTED(DB1_VERSION, "Berkeley DB 1.85 emulation in DB$THIS_VERSION", [ ])
489    for i in db$THIS_VERSION/db_185.h include/db$THIS_VERSION/db_185.h include/db/db_185.h; do
490      if test -f "$THIS_PREFIX/$i"; then
491        THIS_INCLUDE=$THIS_PREFIX/$i
492        break
493      fi
494    done
495  else
496    AC_DEFINE_UNQUOTED(DB1_VERSION, "Unknown DB1", [ ])
497    for i in $PHP_DB1 /usr/local /usr; do
498      if test -f "$i/db1/db.h"; then
499        THIS_PREFIX=$i
500        THIS_INCLUDE=$i/db1/db.h
501        break
502      elif test -f "$i/include/db1/db.h"; then
503        THIS_PREFIX=$i
504        THIS_INCLUDE=$i/include/db1/db.h
505        break
506      elif test -f "$i/include/db.h"; then
507        THIS_PREFIX=$i
508        THIS_INCLUDE=$i/include/db.h
509        break
510      fi
511    done
512    THIS_LIBS=db
513  fi
514  AC_MSG_RESULT([$THIS_LIBS])
515  AC_MSG_CHECKING([for DB1 in header])
516  AC_MSG_RESULT([$THIS_INCLUDE])
517  if test -n "$THIS_INCLUDE"; then
518    PHP_TEMP_LDFLAGS(-L$THIS_PREFIX/$PHP_LIBDIR, -l$THIS_LIBS,[
519      AC_LINK_IFELSE([AC_LANG_PROGRAM([[
520#include "$THIS_INCLUDE"
521      ]],[[
522        DB * dbp = dbopen("", 0, 0, DB_HASH, 0);
523      ]])],[
524        AC_DEFINE_UNQUOTED(DB1_INCLUDE_FILE, "$THIS_INCLUDE", [ ])
525        AC_DEFINE(DBA_DB1, 1, [ ])
526        THIS_RESULT=yes
527      ],[
528        THIS_RESULT=no
529      ])
530    ])
531  fi
532  PHP_DBA_STD_ASSIGN
533  PHP_DBA_STD_CHECK
534  PHP_DBA_STD_ATTACH
535fi
536PHP_DBA_STD_RESULT(db1, DB1)
537
538# DBM
539if test "$PHP_DBM" != "no"; then
540  PHP_DBA_STD_BEGIN
541  if test "$HAVE_QDBM" = "1"; then
542    PHP_DBA_STD_RESULT(dbm, dbm, [You cannot combine --with-dbm with --with-qdbm])
543  fi
544  for i in $PHP_DBM /usr/local /usr; do
545    if test -f "$i/include/dbm.h"; then
546      THIS_PREFIX=$i
547      THIS_INCLUDE=$i/include/dbm.h
548      break
549    elif test -f "$i/include/gdbm/dbm.h"; then
550      THIS_PREFIX=$i
551      THIS_INCLUDE=$i/include/gdbm/dbm.h
552      break
553    fi
554  done
555
556  if test -n "$THIS_INCLUDE"; then
557    for LIB in dbm c gdbm; do
558      PHP_CHECK_LIBRARY($LIB, dbminit, [
559        AC_MSG_CHECKING(for DBM using GDBM)
560        AC_DEFINE_UNQUOTED(DBM_INCLUDE_FILE, "$THIS_INCLUDE", [ ])
561        if test "$LIB" = "gdbm"; then
562          AC_DEFINE_UNQUOTED(DBM_VERSION, "GDBM", [ ])
563          AC_MSG_RESULT(yes)
564        else
565          AC_DEFINE_UNQUOTED(DBM_VERSION, "DBM", [ ])
566          AC_MSG_RESULT(no)
567        fi
568        AC_DEFINE(DBA_DBM, 1, [ ])
569        THIS_LIBS=$LIB
570      ], [], [-L$THIS_PREFIX/$PHP_LIBDIR])
571      if test -n "$THIS_LIBS"; then
572        break
573      fi
574    done
575  fi
576
577  PHP_DBA_STD_ASSIGN
578  PHP_DBA_STD_CHECK
579  PHP_DBA_STD_ATTACH
580fi
581PHP_DBA_STD_RESULT(dbm)
582
583dnl
584dnl Bundled modules that should be enabled by default if any other option is enabled
585dnl
586if test "$PHP_DBA" != "no" || test "$HAVE_DBA" = "1" || test "$with_cdb" = "yes" || test "$enable_inifile" = "yes" || test "$enable_flatfile" = "yes"; then
587  php_dba_enable=yes
588else
589  php_dba_enable=no
590fi
591
592PHP_ARG_WITH(cdb,,
593[  --without-cdb[=DIR]       DBA: CDB support (bundled)], $php_dba_enable, no)
594
595PHP_ARG_ENABLE(inifile,,
596[  --disable-inifile       DBA: INI support (bundled)], $php_dba_enable, no)
597
598PHP_ARG_ENABLE(flatfile,,
599[  --disable-flatfile      DBA: FlatFile support (bundled)], $php_dba_enable, no)
600
601# CDB
602if test "$PHP_CDB" = "yes"; then
603  AC_DEFINE(DBA_CDB_BUILTIN, 1, [ ])
604  AC_DEFINE(DBA_CDB_MAKE, 1, [ ])
605  AC_DEFINE(DBA_CDB, 1, [ ])
606  cdb_sources="libcdb/cdb.c libcdb/cdb_make.c libcdb/uint32.c"
607  THIS_RESULT="builtin"
608elif test "$PHP_CDB" != "no"; then
609  PHP_DBA_STD_BEGIN
610  for i in $PHP_CDB /usr/local /usr; do
611    if test -f "$i/include/cdb.h"; then
612      THIS_PREFIX=$i
613      THIS_INCLUDE=$i/include/cdb.h
614      break
615    fi
616  done
617
618  if test -n "$THIS_INCLUDE"; then
619    for LIB in cdb c; do
620      PHP_CHECK_LIBRARY($LIB, cdb_read, [
621        AC_DEFINE_UNQUOTED(CDB_INCLUDE_FILE, "$THIS_INCLUDE", [ ])
622        AC_DEFINE(DBA_CDB, 1, [ ])
623        THIS_LIBS=$LIB
624      ], [], [-L$THIS_PREFIX/$PHP_LIBDIR])
625      if test -n "$THIS_LIBS"; then
626        break
627      fi
628    done
629  fi
630
631  PHP_DBA_STD_ASSIGN
632  PHP_DBA_STD_CHECK
633  PHP_DBA_STD_ATTACH
634fi
635PHP_DBA_STD_RESULT(cdb)
636
637# INIFILE
638if test "$PHP_INIFILE" != "no"; then
639  AC_DEFINE(DBA_INIFILE, 1, [ ])
640  ini_sources="libinifile/inifile.c"
641  THIS_RESULT="builtin"
642fi
643PHP_DBA_STD_RESULT(inifile, [INI File])
644
645# FLATFILE
646if test "$PHP_FLATFILE" != "no"; then
647  AC_DEFINE(DBA_FLATFILE, 1, [ ])
648  flat_sources="libflatfile/flatfile.c"
649  THIS_RESULT="builtin"
650fi
651PHP_DBA_STD_RESULT(FlatFile, FlatFile)
652
653dnl
654dnl Extension setup
655dnl
656AC_MSG_CHECKING([whether to enable DBA interface])
657if test "$HAVE_DBA" = "1"; then
658  if test "$ext_shared" = "yes"; then
659    AC_MSG_RESULT([yes, shared])
660  else
661    AC_MSG_RESULT([yes])
662  fi
663  AC_DEFINE(HAVE_DBA, 1, [ ])
664  PHP_NEW_EXTENSION(dba, dba.c dba_cdb.c dba_dbm.c dba_gdbm.c dba_ndbm.c dba_db1.c dba_db2.c dba_db3.c dba_db4.c dba_flatfile.c dba_inifile.c dba_qdbm.c dba_tcadb.c dba_lmdb.c $cdb_sources $flat_sources $ini_sources, $ext_shared)
665  PHP_ADD_BUILD_DIR($ext_builddir/libinifile)
666  PHP_ADD_BUILD_DIR($ext_builddir/libcdb)
667  PHP_ADD_BUILD_DIR($ext_builddir/libflatfile)
668  PHP_SUBST(DBA_SHARED_LIBADD)
669else
670  AC_MSG_RESULT(no)
671fi
672