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