1
+ dnl
2
+ dnl PHP_DBA_STD_BEGIN
3
+ dnl
1
4
dnl Suppose we need FlatFile if no support or only CDB is used.
2
- AC_DEFUN ( [ PHP_DBA_STD_BEGIN ] , [
3
- unset THIS_INCLUDE THIS_LIBS THIS_LFLAGS THIS_PREFIX THIS_RESULT
4
- ] )
5
+ dnl
6
+ AC_DEFUN ( [ PHP_DBA_STD_BEGIN ] ,
7
+ [ unset THIS_INCLUDE THIS_LIBS THIS_LFLAGS THIS_PREFIX THIS_RESULT ] )
5
8
9
+ dnl
10
+ dnl PHP_TEMP_LDFLAGS(ldflags, libs)
11
+ dnl
12
+ dnl Save and restore linker flags.
13
+ dnl
6
14
AC_DEFUN ( [ PHP_TEMP_LDFLAGS] ,[
7
15
old_LDFLAGS=$LDFLAGS
8
16
LDFLAGS="$1 $LDFLAGS"
@@ -13,32 +21,45 @@ AC_DEFUN([PHP_TEMP_LDFLAGS],[
13
21
LIBS=$old_LIBS
14
22
] )
15
23
16
- dnl Assign INCLUDE/LFLAGS from PREFIX
24
+ dnl
25
+ dnl PHP_DBA_STD_ASSIGN
26
+ dnl
27
+ dnl Assign INCLUDE/LFLAGS from PREFIX.
28
+ dnl
17
29
AC_DEFUN ( [ PHP_DBA_STD_ASSIGN] ,[
18
30
if test -n "$THIS_PREFIX" && test "$THIS_PREFIX" != "/usr"; then
19
31
THIS_LFLAGS=$THIS_PREFIX/$PHP_LIBDIR
20
32
fi
21
33
] )
22
34
23
- dnl Standard check
35
+ dnl
36
+ dnl PHP_DBA_STD_CHECK
37
+ dnl
38
+ dnl Check if includes and libraries are set.
39
+ dnl
24
40
AC_DEFUN ( [ PHP_DBA_STD_CHECK] ,[
25
41
THIS_RESULT=yes
26
- if test -z "$THIS_INCLUDE"; then
27
- AC_MSG_ERROR ( [ DBA: Could not find necessary header file(s).] )
28
- fi
29
- if test -z "$THIS_LIBS"; then
30
- AC_MSG_ERROR ( [ DBA: Could not find necessary library.] )
31
- fi
42
+ AS_VAR_IF ( [ THIS_INCLUDE] ,,
43
+ [ AC_MSG_ERROR ( [ DBA: Could not find necessary header file(s).] ) ] )
44
+ AS_VAR_IF ( [ THIS_LIBS] ,,
45
+ [ AC_MSG_ERROR ( [ DBA: Could not find necessary library.] ) ] )
32
46
] )
33
47
34
- dnl Attach THIS_x to DBA_x
48
+ dnl
49
+ dnl PHP_DBA_STD_ATTACH
50
+ dnl
51
+ dnl Attach THIS_x to DBA_x.
52
+ dnl
35
53
AC_DEFUN ( [ PHP_DBA_STD_ATTACH] ,[
36
54
PHP_ADD_LIBRARY_WITH_PATH([ $THIS_LIBS] , [ $THIS_LFLAGS] , [ DBA_SHARED_LIBADD] )
37
55
unset THIS_INCLUDE THIS_LIBS THIS_LFLAGS THIS_PREFIX
38
56
] )
39
57
40
- dnl Print the result message
41
- dnl parameters(name [, full name [, empty or error message]])
58
+ dnl
59
+ dnl PHP_DBA_STD_RESULT(name [, full name [, empty or error message]])
60
+ dnl
61
+ dnl Print the result message.
62
+ dnl
42
63
AC_DEFUN ( [ PHP_DBA_STD_RESULT] ,[
43
64
THIS_NAME=[ ] translit ( $1 ,a-z0-9- ,A-Z0-9_ )
44
65
if test -n "$2 "; then
@@ -167,14 +188,15 @@ if test "$PHP_QDBM" != "no"; then
167
188
PHP_DBA_STD_CHECK
168
189
PHP_DBA_STD_ATTACH
169
190
fi
170
- PHP_DBA_STD_RESULT(qdbm)
191
+ PHP_DBA_STD_RESULT([ qdbm] )
171
192
172
193
dnl GDBM
173
194
if test "$PHP_GDBM" != "no"; then
174
195
PHP_DBA_STD_BEGIN
175
- if test "$HAVE_QDBM" = "1"; then
176
- PHP_DBA_STD_RESULT(gdbm, gdbm, [ You cannot combine --with-gdbm with --with-qdbm] )
177
- fi
196
+ AS_VAR_IF ( [ HAVE_QDBM] , [ 1] ,
197
+ [ PHP_DBA_STD_RESULT([ gdbm] ,
198
+ [ gdbm] ,
199
+ [ You cannot combine --with-gdbm with --with-qdbm] )] )
178
200
for i in $PHP_GDBM /usr/local /usr; do
179
201
if test -f "$i/include/gdbm.h"; then
180
202
THIS_PREFIX=$i
@@ -197,7 +219,7 @@ if test "$PHP_GDBM" != "no"; then
197
219
PHP_DBA_STD_CHECK
198
220
PHP_DBA_STD_ATTACH
199
221
fi
200
- PHP_DBA_STD_RESULT(gdbm)
222
+ PHP_DBA_STD_RESULT([ gdbm] )
201
223
202
224
dnl NDBM
203
225
if test "$PHP_NDBM" != "no"; then
@@ -233,7 +255,7 @@ if test "$PHP_NDBM" != "no"; then
233
255
PHP_DBA_STD_CHECK
234
256
PHP_DBA_STD_ATTACH
235
257
fi
236
- PHP_DBA_STD_RESULT(ndbm)
258
+ PHP_DBA_STD_RESULT([ ndbm] )
237
259
238
260
dnl TCADB
239
261
if test "$PHP_TCADB" != "no"; then
@@ -266,7 +288,7 @@ if test "$PHP_TCADB" != "no"; then
266
288
PHP_DBA_STD_CHECK
267
289
PHP_DBA_STD_ATTACH
268
290
fi
269
- PHP_DBA_STD_RESULT(tcadb)
291
+ PHP_DBA_STD_RESULT([ tcadb] )
270
292
271
293
dnl LMDB
272
294
if test "$PHP_LMDB" != "no"; then
@@ -299,70 +321,65 @@ if test "$PHP_LMDB" != "no"; then
299
321
PHP_DBA_STD_CHECK
300
322
PHP_DBA_STD_ATTACH
301
323
fi
302
- PHP_DBA_STD_RESULT(lmdb)
324
+ PHP_DBA_STD_RESULT([ lmdb] )
303
325
304
- dnl Berkeley specific (library and version test)
305
- dnl parameters(version, library list, function)
326
+ dnl
327
+ dnl PHP_DBA_DB_CHECK(version, library list, function)
328
+ dnl
329
+ dnl Berkeley specific (library and version test).
330
+ dnl
306
331
AC_DEFUN ( [ PHP_DBA_DB_CHECK] ,[
307
- if test -z "$THIS_INCLUDE"; then
308
- AC_MSG_ERROR ( [ DBA: Could not find necessary header file(s).] )
309
- fi
332
+ AS_VAR_IF ( [ THIS_INCLUDE] ,,
333
+ [ AC_MSG_ERROR ( [ DBA: Could not find necessary header file(s).] ) ] )
310
334
for LIB in $2 ; do
311
335
if test -f $THIS_PREFIX/$PHP_LIBDIR/lib$LIB.a || test -f $THIS_PREFIX/$PHP_LIBDIR/lib$LIB.$SHLIB_SUFFIX_NAME; then
312
336
lib_found="";
313
- PHP_TEMP_LDFLAGS(-L$THIS_PREFIX/$PHP_LIBDIR, -l$LIB,[
314
- AC_LINK_IFELSE ( [ AC_LANG_PROGRAM ( [ [
315
- #include "$THIS_INCLUDE"
316
- ] ] ,[ [
317
- $3 ;
318
- ] ] ) ] ,[
319
- AC_EGREP_CPP ( yes ,[
337
+ PHP_TEMP_LDFLAGS([ -L$THIS_PREFIX/$PHP_LIBDIR] , [ -l$LIB] ,
338
+ [ AC_LINK_IFELSE ( [ AC_LANG_PROGRAM ( [ #include "$THIS_INCLUDE"] ,
339
+ [ $3 ;] ) ] ,
340
+ [ AC_EGREP_CPP ( [ yes] , [
320
341
#include "$THIS_INCLUDE"
321
342
#if DB_VERSION_MAJOR == $1 || ($1 == 4 && DB_VERSION_MAJOR == 5)
322
343
yes
323
344
#endif
324
345
] ,[
325
346
THIS_LIBS=$LIB
326
347
lib_found=1
327
- ] )
328
- ] ,[ ] )
329
- ] )
348
+ ] ) ] ,
349
+ [ ] ) ] )
330
350
if test -n "$lib_found"; then
331
351
lib_found="";
332
352
break;
333
353
fi
334
354
fi
335
355
done
336
- if test -z "$THIS_LIBS"; then
337
- AC_MSG_CHECKING ( [ for DB$1 major version] )
338
- AC_MSG_ERROR ( [ Header contains different version] )
339
- fi
356
+
357
+ AS_VAR_IF ( [ THIS_LIBS] ,, [ AC_MSG_FAILURE ( m4_text_wrap ( [
358
+ DB$1 major version check failed: header contains different version
359
+ ] ) ) ] )
360
+
340
361
if test "$1 " = "4"; then
341
362
AC_MSG_CHECKING ( [ for DB4 minor version and patch level] )
342
- AC_EGREP_CPP ( yes , [
363
+ AC_EGREP_CPP ( [ yes] , [
343
364
#include "$THIS_INCLUDE"
344
365
#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)
345
366
yes
346
367
#endif
347
- ] ,[
348
- AC_MSG_RESULT ( [ ok] )
349
- ] ,[
350
- AC_MSG_ERROR ( [ Version 4.1 requires patch level 25] )
351
- ] )
368
+ ] ,
369
+ [ AC_MSG_RESULT ( [ ok] ) ] ,
370
+ [ AC_MSG_ERROR ( [ Version 4.1 requires patch level 25] ) ] )
352
371
fi
353
- if test "$ ext_shared" = " yes"; then
372
+ AS_VAR_IF ( [ ext_shared] , [ yes] , [
354
373
AC_MSG_CHECKING ( [ if dba can be used as shared extension] )
355
- AC_EGREP_CPP ( yes , [
374
+ AC_EGREP_CPP ( [ yes] , [
356
375
#include "$THIS_INCLUDE"
357
376
#if DB_VERSION_MAJOR > 3 || (DB_VERSION_MAJOR == 3 && DB_VERSION_MINOR > 2)
358
377
yes
359
378
#endif
360
- ] ,[
361
- AC_MSG_RESULT ( [ yes] )
362
- ] ,[
363
- AC_MSG_ERROR ( [ At least version 3.3 is required] )
364
- ] )
365
- fi
379
+ ] ,
380
+ [ AC_MSG_RESULT ( [ yes] ) ] ,
381
+ [ AC_MSG_ERROR ( [ At least version 3.3 is required] ) ] )
382
+ ] )
366
383
if test -n "$THIS_LIBS"; then
367
384
AC_DEFINE_UNQUOTED ( [ DBA_DB$1 ] , [ 1] ,
368
385
[ Define to 1 if the dba extension uses the Berkeley DB version $1 (DB$1 )
@@ -444,14 +461,15 @@ if test "$PHP_DB4" != "no"; then
444
461
done
445
462
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)] )
446
463
fi
447
- PHP_DBA_STD_RESULT(db4, Berkeley DB4)
464
+ PHP_DBA_STD_RESULT([ db4] , [ Berkeley DB4] )
448
465
449
466
dnl DB3
450
467
if test "$PHP_DB3" != "no"; then
451
468
PHP_DBA_STD_BEGIN
452
- if test "$HAVE_DB4" = "1"; then
453
- PHP_DBA_STD_RESULT(db3, Berkeley DB3, [ You cannot combine --with-db3 with --with-db4] )
454
- fi
469
+ AS_VAR_IF ( [ HAVE_DB4] , [ 1] ,
470
+ [ PHP_DBA_STD_RESULT([ db3] ,
471
+ [ Berkeley DB3] ,
472
+ [ You cannot combine --with-db3 with --with-db4] )] )
455
473
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
456
474
if test -f "$i/db3/db.h"; then
457
475
THIS_PREFIX=$i
@@ -477,13 +495,15 @@ if test "$PHP_DB3" != "no"; then
477
495
done
478
496
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)] )
479
497
fi
480
- PHP_DBA_STD_RESULT(db3, Berkeley DB3)
498
+ PHP_DBA_STD_RESULT([ db3] , [ Berkeley DB3] )
481
499
482
500
dnl DB2
483
501
if test "$PHP_DB2" != "no"; then
484
502
PHP_DBA_STD_BEGIN
485
503
if test "$HAVE_DB3" = "1" || test "$HAVE_DB4" = "1"; then
486
- PHP_DBA_STD_RESULT(db2, Berkeley DB2, [ You cannot combine --with-db2 with --with-db3 or --with-db4] )
504
+ PHP_DBA_STD_RESULT([ db2] ,
505
+ [ Berkeley DB2] ,
506
+ [ You cannot combine --with-db2 with --with-db3 or --with-db4] )
487
507
fi
488
508
for i in $PHP_DB2 $PHP_DB2/BerkeleyDB /usr/BerkeleyDB /usr/local /usr; do
489
509
if test -f "$i/db2/db.h"; then
@@ -510,7 +530,7 @@ if test "$PHP_DB2" != "no"; then
510
530
done
511
531
PHP_DBA_DB_CHECK(2, db-2 db2 db, [ (void)db_appinit("", NULL, (DB_ENV*)0, 0)] )
512
532
fi
513
- PHP_DBA_STD_RESULT(db2, Berkeley DB2)
533
+ PHP_DBA_STD_RESULT([ db2] , [ Berkeley DB2] )
514
534
515
535
dnl DB1
516
536
if test "$PHP_DB1" != "no"; then
@@ -562,35 +582,31 @@ if test "$PHP_DB1" != "no"; then
562
582
AC_MSG_CHECKING ( [ for DB1 in header] )
563
583
AC_MSG_RESULT ( [ $THIS_INCLUDE] )
564
584
if test -n "$THIS_INCLUDE"; then
565
- PHP_TEMP_LDFLAGS(-L$THIS_PREFIX/$PHP_LIBDIR, -l$THIS_LIBS,[
566
- AC_LINK_IFELSE ( [ AC_LANG_PROGRAM ( [ [
567
- #include "$THIS_INCLUDE"
568
- ] ] ,[ [
569
- DB * dbp = dbopen("", 0, 0, DB_HASH, 0);
570
- ] ] ) ] ,[
571
- AC_DEFINE_UNQUOTED ( [ DB1_INCLUDE_FILE] , [ "$THIS_INCLUDE"] ,
585
+ PHP_TEMP_LDFLAGS([ -L$THIS_PREFIX/$PHP_LIBDIR] , [ -l$THIS_LIBS] ,
586
+ [ AC_LINK_IFELSE ( [ AC_LANG_PROGRAM ( [ #include "$THIS_INCLUDE"] ,
587
+ [ DB * dbp = dbopen("", 0, 0, DB_HASH, 0);] ) ] ,
588
+ [ AC_DEFINE_UNQUOTED ( [ DB1_INCLUDE_FILE] , [ "$THIS_INCLUDE"] ,
572
589
[ The DB1 handler header file.] )
573
590
AC_DEFINE ( [ DBA_DB1] , [ 1] ,
574
591
[ Define to 1 if the dba extension uses the Berkeley DB version 1 (DB1)
575
592
handler.] )
576
593
THIS_RESULT=yes
577
- ] ,[
578
- THIS_RESULT=no
579
- ] )
580
- ] )
594
+ ] ,
595
+ [ THIS_RESULT=no] ) ] )
581
596
fi
582
597
PHP_DBA_STD_ASSIGN
583
598
PHP_DBA_STD_CHECK
584
599
PHP_DBA_STD_ATTACH
585
600
fi
586
- PHP_DBA_STD_RESULT(db1, DB1)
601
+ PHP_DBA_STD_RESULT([ db1] , [ DB1] )
587
602
588
603
dnl DBM
589
604
if test "$PHP_DBM" != "no"; then
590
605
PHP_DBA_STD_BEGIN
591
- if test "$HAVE_QDBM" = "1"; then
592
- PHP_DBA_STD_RESULT(dbm, dbm, [ You cannot combine --with-dbm with --with-qdbm] )
593
- fi
606
+ AS_VAR_IF ( [ HAVE_QDBM] , [ 1] ,
607
+ [ PHP_DBA_STD_RESULT([ dbm] ,
608
+ [ dbm] ,
609
+ [ You cannot combine --with-dbm with --with-qdbm] )] )
594
610
for i in $PHP_DBM /usr/local /usr; do
595
611
if test -f "$i/include/dbm.h"; then
596
612
THIS_PREFIX=$i
@@ -632,7 +648,7 @@ if test "$PHP_DBM" != "no"; then
632
648
PHP_DBA_STD_CHECK
633
649
PHP_DBA_STD_ATTACH
634
650
fi
635
- PHP_DBA_STD_RESULT(dbm)
651
+ PHP_DBA_STD_RESULT([ dbm] )
636
652
637
653
dnl Bundled modules that should be enabled by default if any other option is
638
654
dnl enabled
@@ -697,7 +713,7 @@ elif test "$PHP_CDB" != "no"; then
697
713
PHP_DBA_STD_CHECK
698
714
PHP_DBA_STD_ATTACH
699
715
fi
700
- PHP_DBA_STD_RESULT(cdb)
716
+ PHP_DBA_STD_RESULT([ cdb] )
701
717
702
718
dnl INIFILE
703
719
if test "$PHP_INIFILE" != "no"; then
@@ -706,7 +722,7 @@ if test "$PHP_INIFILE" != "no"; then
706
722
ini_sources="libinifile/inifile.c"
707
723
THIS_RESULT="builtin"
708
724
fi
709
- PHP_DBA_STD_RESULT(inifile, [ INI File] )
725
+ PHP_DBA_STD_RESULT([ inifile] , [ INI File] )
710
726
711
727
dnl FLATFILE
712
728
if test "$PHP_FLATFILE" != "no"; then
@@ -715,18 +731,17 @@ if test "$PHP_FLATFILE" != "no"; then
715
731
flat_sources="libflatfile/flatfile.c"
716
732
THIS_RESULT="builtin"
717
733
fi
718
- PHP_DBA_STD_RESULT(FlatFile, FlatFile)
734
+ PHP_DBA_STD_RESULT([ FlatFile] , [ FlatFile] )
719
735
720
736
dnl
721
737
dnl Extension setup
722
738
dnl
723
739
AC_MSG_CHECKING ( [ whether to enable DBA interface] )
724
- if test "$HAVE_DBA" = "1"; then
725
- if test "$ext_shared" = "yes"; then
726
- AC_MSG_RESULT ( [ yes, shared] )
727
- else
728
- AC_MSG_RESULT ( [ yes] )
729
- fi
740
+ AS_VAR_IF ( [ HAVE_DBA] , [ 1] , [
741
+ AS_VAR_IF ( [ ext_shared] , [ yes] ,
742
+ [ AC_MSG_RESULT ( [ yes, shared] ) ] ,
743
+ [ AC_MSG_RESULT ( [ yes] ) ] )
744
+
730
745
AC_DEFINE ( [ HAVE_DBA] , [ 1] ,
731
746
[ Define to 1 if the PHP extension 'dba' is available.] )
732
747
PHP_NEW_EXTENSION([ dba] , m4_normalize ( [
@@ -754,6 +769,5 @@ if test "$HAVE_DBA" = "1"; then
754
769
PHP_ADD_BUILD_DIR([ $ext_builddir/libflatfile] )
755
770
PHP_ADD_BUILD_DIR([ $ext_builddir/libinifile] )
756
771
PHP_SUBST([ DBA_SHARED_LIBADD] )
757
- else
758
- AC_MSG_RESULT ( [ no] )
759
- fi
772
+ ] ,
773
+ [ AC_MSG_RESULT ( [ no] ) ] )
0 commit comments