Skip to content

Commit 4f6f4fb

Browse files
authored
Autotools: Sync CS in ext/dba (#15608)
- Macro headers synced with current PHP style (a minor description added and parameters) - macro arguments quoted - redundant double quotes reduces - AS_VAR_IF macros used - Redundant check message removed because there is already error thrown right after it
1 parent d9d49b2 commit 4f6f4fb

File tree

1 file changed

+104
-90
lines changed

1 file changed

+104
-90
lines changed

ext/dba/config.m4

Lines changed: 104 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
1+
dnl
2+
dnl PHP_DBA_STD_BEGIN
3+
dnl
14
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])
58

9+
dnl
10+
dnl PHP_TEMP_LDFLAGS(ldflags, libs)
11+
dnl
12+
dnl Save and restore linker flags.
13+
dnl
614
AC_DEFUN([PHP_TEMP_LDFLAGS],[
715
old_LDFLAGS=$LDFLAGS
816
LDFLAGS="$1 $LDFLAGS"
@@ -13,32 +21,45 @@ AC_DEFUN([PHP_TEMP_LDFLAGS],[
1321
LIBS=$old_LIBS
1422
])
1523

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
1729
AC_DEFUN([PHP_DBA_STD_ASSIGN],[
1830
if test -n "$THIS_PREFIX" && test "$THIS_PREFIX" != "/usr"; then
1931
THIS_LFLAGS=$THIS_PREFIX/$PHP_LIBDIR
2032
fi
2133
])
2234

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
2440
AC_DEFUN([PHP_DBA_STD_CHECK],[
2541
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.])])
3246
])
3347

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
3553
AC_DEFUN([PHP_DBA_STD_ATTACH],[
3654
PHP_ADD_LIBRARY_WITH_PATH([$THIS_LIBS], [$THIS_LFLAGS], [DBA_SHARED_LIBADD])
3755
unset THIS_INCLUDE THIS_LIBS THIS_LFLAGS THIS_PREFIX
3856
])
3957

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
4263
AC_DEFUN([PHP_DBA_STD_RESULT],[
4364
THIS_NAME=[]translit($1,a-z0-9-,A-Z0-9_)
4465
if test -n "$2"; then
@@ -167,14 +188,15 @@ if test "$PHP_QDBM" != "no"; then
167188
PHP_DBA_STD_CHECK
168189
PHP_DBA_STD_ATTACH
169190
fi
170-
PHP_DBA_STD_RESULT(qdbm)
191+
PHP_DBA_STD_RESULT([qdbm])
171192

172193
dnl GDBM
173194
if test "$PHP_GDBM" != "no"; then
174195
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])])
178200
for i in $PHP_GDBM /usr/local /usr; do
179201
if test -f "$i/include/gdbm.h"; then
180202
THIS_PREFIX=$i
@@ -197,7 +219,7 @@ if test "$PHP_GDBM" != "no"; then
197219
PHP_DBA_STD_CHECK
198220
PHP_DBA_STD_ATTACH
199221
fi
200-
PHP_DBA_STD_RESULT(gdbm)
222+
PHP_DBA_STD_RESULT([gdbm])
201223

202224
dnl NDBM
203225
if test "$PHP_NDBM" != "no"; then
@@ -233,7 +255,7 @@ if test "$PHP_NDBM" != "no"; then
233255
PHP_DBA_STD_CHECK
234256
PHP_DBA_STD_ATTACH
235257
fi
236-
PHP_DBA_STD_RESULT(ndbm)
258+
PHP_DBA_STD_RESULT([ndbm])
237259

238260
dnl TCADB
239261
if test "$PHP_TCADB" != "no"; then
@@ -266,7 +288,7 @@ if test "$PHP_TCADB" != "no"; then
266288
PHP_DBA_STD_CHECK
267289
PHP_DBA_STD_ATTACH
268290
fi
269-
PHP_DBA_STD_RESULT(tcadb)
291+
PHP_DBA_STD_RESULT([tcadb])
270292

271293
dnl LMDB
272294
if test "$PHP_LMDB" != "no"; then
@@ -299,70 +321,65 @@ if test "$PHP_LMDB" != "no"; then
299321
PHP_DBA_STD_CHECK
300322
PHP_DBA_STD_ATTACH
301323
fi
302-
PHP_DBA_STD_RESULT(lmdb)
324+
PHP_DBA_STD_RESULT([lmdb])
303325

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
306331
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).])])
310334
for LIB in $2; do
311335
if test -f $THIS_PREFIX/$PHP_LIBDIR/lib$LIB.a || test -f $THIS_PREFIX/$PHP_LIBDIR/lib$LIB.$SHLIB_SUFFIX_NAME; then
312336
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], [
320341
#include "$THIS_INCLUDE"
321342
#if DB_VERSION_MAJOR == $1 || ($1 == 4 && DB_VERSION_MAJOR == 5)
322343
yes
323344
#endif
324345
],[
325346
THIS_LIBS=$LIB
326347
lib_found=1
327-
])
328-
],[])
329-
])
348+
])],
349+
[])])
330350
if test -n "$lib_found"; then
331351
lib_found="";
332352
break;
333353
fi
334354
fi
335355
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+
340361
if test "$1" = "4"; then
341362
AC_MSG_CHECKING([for DB4 minor version and patch level])
342-
AC_EGREP_CPP(yes,[
363+
AC_EGREP_CPP([yes], [
343364
#include "$THIS_INCLUDE"
344365
#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)
345366
yes
346367
#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])])
352371
fi
353-
if test "$ext_shared" = "yes"; then
372+
AS_VAR_IF([ext_shared], [yes], [
354373
AC_MSG_CHECKING([if dba can be used as shared extension])
355-
AC_EGREP_CPP(yes,[
374+
AC_EGREP_CPP([yes], [
356375
#include "$THIS_INCLUDE"
357376
#if DB_VERSION_MAJOR > 3 || (DB_VERSION_MAJOR == 3 && DB_VERSION_MINOR > 2)
358377
yes
359378
#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+
])
366383
if test -n "$THIS_LIBS"; then
367384
AC_DEFINE_UNQUOTED([DBA_DB$1], [1],
368385
[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
444461
done
445462
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)])
446463
fi
447-
PHP_DBA_STD_RESULT(db4,Berkeley DB4)
464+
PHP_DBA_STD_RESULT([db4], [Berkeley DB4])
448465

449466
dnl DB3
450467
if test "$PHP_DB3" != "no"; then
451468
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])])
455473
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
456474
if test -f "$i/db3/db.h"; then
457475
THIS_PREFIX=$i
@@ -477,13 +495,15 @@ if test "$PHP_DB3" != "no"; then
477495
done
478496
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)])
479497
fi
480-
PHP_DBA_STD_RESULT(db3,Berkeley DB3)
498+
PHP_DBA_STD_RESULT([db3], [Berkeley DB3])
481499

482500
dnl DB2
483501
if test "$PHP_DB2" != "no"; then
484502
PHP_DBA_STD_BEGIN
485503
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])
487507
fi
488508
for i in $PHP_DB2 $PHP_DB2/BerkeleyDB /usr/BerkeleyDB /usr/local /usr; do
489509
if test -f "$i/db2/db.h"; then
@@ -510,7 +530,7 @@ if test "$PHP_DB2" != "no"; then
510530
done
511531
PHP_DBA_DB_CHECK(2, db-2 db2 db, [(void)db_appinit("", NULL, (DB_ENV*)0, 0)])
512532
fi
513-
PHP_DBA_STD_RESULT(db2, Berkeley DB2)
533+
PHP_DBA_STD_RESULT([db2], [Berkeley DB2])
514534

515535
dnl DB1
516536
if test "$PHP_DB1" != "no"; then
@@ -562,35 +582,31 @@ if test "$PHP_DB1" != "no"; then
562582
AC_MSG_CHECKING([for DB1 in header])
563583
AC_MSG_RESULT([$THIS_INCLUDE])
564584
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"],
572589
[The DB1 handler header file.])
573590
AC_DEFINE([DBA_DB1], [1],
574591
[Define to 1 if the dba extension uses the Berkeley DB version 1 (DB1)
575592
handler.])
576593
THIS_RESULT=yes
577-
],[
578-
THIS_RESULT=no
579-
])
580-
])
594+
],
595+
[THIS_RESULT=no])])
581596
fi
582597
PHP_DBA_STD_ASSIGN
583598
PHP_DBA_STD_CHECK
584599
PHP_DBA_STD_ATTACH
585600
fi
586-
PHP_DBA_STD_RESULT(db1, DB1)
601+
PHP_DBA_STD_RESULT([db1], [DB1])
587602

588603
dnl DBM
589604
if test "$PHP_DBM" != "no"; then
590605
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])])
594610
for i in $PHP_DBM /usr/local /usr; do
595611
if test -f "$i/include/dbm.h"; then
596612
THIS_PREFIX=$i
@@ -632,7 +648,7 @@ if test "$PHP_DBM" != "no"; then
632648
PHP_DBA_STD_CHECK
633649
PHP_DBA_STD_ATTACH
634650
fi
635-
PHP_DBA_STD_RESULT(dbm)
651+
PHP_DBA_STD_RESULT([dbm])
636652

637653
dnl Bundled modules that should be enabled by default if any other option is
638654
dnl enabled
@@ -697,7 +713,7 @@ elif test "$PHP_CDB" != "no"; then
697713
PHP_DBA_STD_CHECK
698714
PHP_DBA_STD_ATTACH
699715
fi
700-
PHP_DBA_STD_RESULT(cdb)
716+
PHP_DBA_STD_RESULT([cdb])
701717

702718
dnl INIFILE
703719
if test "$PHP_INIFILE" != "no"; then
@@ -706,7 +722,7 @@ if test "$PHP_INIFILE" != "no"; then
706722
ini_sources="libinifile/inifile.c"
707723
THIS_RESULT="builtin"
708724
fi
709-
PHP_DBA_STD_RESULT(inifile, [INI File])
725+
PHP_DBA_STD_RESULT([inifile], [INI File])
710726

711727
dnl FLATFILE
712728
if test "$PHP_FLATFILE" != "no"; then
@@ -715,18 +731,17 @@ if test "$PHP_FLATFILE" != "no"; then
715731
flat_sources="libflatfile/flatfile.c"
716732
THIS_RESULT="builtin"
717733
fi
718-
PHP_DBA_STD_RESULT(FlatFile, FlatFile)
734+
PHP_DBA_STD_RESULT([FlatFile], [FlatFile])
719735

720736
dnl
721737
dnl Extension setup
722738
dnl
723739
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+
730745
AC_DEFINE([HAVE_DBA], [1],
731746
[Define to 1 if the PHP extension 'dba' is available.])
732747
PHP_NEW_EXTENSION([dba], m4_normalize([
@@ -754,6 +769,5 @@ if test "$HAVE_DBA" = "1"; then
754769
PHP_ADD_BUILD_DIR([$ext_builddir/libflatfile])
755770
PHP_ADD_BUILD_DIR([$ext_builddir/libinifile])
756771
PHP_SUBST([DBA_SHARED_LIBADD])
757-
else
758-
AC_MSG_RESULT([no])
759-
fi
772+
],
773+
[AC_MSG_RESULT([no])])

0 commit comments

Comments
 (0)