Skip to content

Commit c74cc07

Browse files
committed
Fix ext/dba
- Berkeley DB adjusted based on versions - GPL-licensed libraries emit warnings where possible as these shouldn't be linked to PHP. Removal of these annoyances pending in the near future. - all-enabled preset adjusted for smoother experience - cdb in C library removed; If such system is found, it will be refactored - EXT_DBA_DB2 and EXT_DBA_DB3 configuration options removed as they are redundant; Berkeley DB version is checked from the db.h header and preprocessor macros automatically set based on that - The Tkrzw library link removed as this would need a new dba handler - ext/dba configuration refactored and sorted according to the configuration options order
1 parent b12a167 commit c74cc07

File tree

6 files changed

+197
-110
lines changed

6 files changed

+197
-110
lines changed

.github/workflows/ci.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ jobs:
7272
libbz2-dev \
7373
libcurl4-openssl-dev \
7474
libdb5.3++-dev \
75-
libdb-dev \
7675
libenchant-2-dev \
7776
libpng-dev \
7877
libgmp-dev \
@@ -103,9 +102,8 @@ jobs:
103102
libcapstone-dev \
104103
libedit-dev \
105104
libcdb-dev \
106-
libgdbm-dev \
107-
libgdbm-compat-dev \
108105
liblmdb-dev \
106+
libqdbm-dev \
109107
libtokyocabinet-dev \
110108
libsnmp-dev \
111109
snmpd \

cmake/cmake/modules/FindBerkeleyDB.cmake

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Module defines the following `IMPORTED` target(s):
1010
* `BerkeleyDB_FOUND` - Whether the package has been found.
1111
* `BerkeleyDB_INCLUDE_DIRS`- Include directories needed to use this package.
1212
* `BerkeleyDB_LIBRARIES`- Libraries needed to link to the package library.
13+
* `BerkeleyDB_VERSION` - Package version, if found.
1314
1415
## Cache variables
1516
@@ -42,6 +43,7 @@ set(_reason "")
4243
find_path(
4344
BerkeleyDB_INCLUDE_DIR
4445
NAMES db.h
46+
PATH_SUFFIXES db
4547
DOC "Directory containing Berkeley DB library headers"
4648
)
4749

@@ -63,12 +65,15 @@ if(BerkeleyDB_USE_DB1)
6365
find_path(
6466
BerkeleyDB_DB1_INCLUDE_DIR
6567
NAMES db_185.h
68+
PATH_SUFFIXES db
6669
DOC "Directory containing Berkeley DB db_185.h header for v1 emulation"
6770
)
6871

72+
message(CHECK_START "Checking for Berkeley DB 1.x support/emulation")
6973
cmake_push_check_state(RESET)
7074
set(CMAKE_REQUIRED_LIBRARIES ${BerkeleyDB_LIBRARY})
7175
set(CMAKE_REQUIRED_INCLUDES ${BerkeleyDB_DB1_INCLUDE_DIR})
76+
set(CMAKE_REQUIRED_QUIET TRUE)
7277

7378
check_source_compiles(C [[
7479
#include <db_185.h>
@@ -82,8 +87,9 @@ if(BerkeleyDB_USE_DB1)
8287

8388
if(NOT _berkeleydb_db1_sanity_check)
8489
unset(BerkeleyDB_DB1_INCLUDE_DIR CACHE)
90+
message(CHECK_FAIL "disabled, not found")
8591
else()
86-
message(WARNING "Berkeley DB 1.x support/emulation not enabled")
92+
message(CHECK_PASS "enabled")
8793
endif()
8894
endif()
8995

@@ -92,6 +98,7 @@ if(BerkeleyDB_LIBRARY)
9298
cmake_push_check_state(RESET)
9399
set(CMAKE_REQUIRED_LIBRARIES ${BerkeleyDB_LIBRARY})
94100
set(CMAKE_REQUIRED_INCLUDES ${BerkeleyDB_INCLUDE_DIR})
101+
set(CMAKE_REQUIRED_QUIET TRUE)
95102

96103
check_source_compiles(C [[
97104
#include <db.h>
@@ -109,6 +116,32 @@ if(BerkeleyDB_LIBRARY)
109116
endif()
110117
endif()
111118

119+
# Get package version.
120+
block(PROPAGATE BerkeleyDB_VERSION)
121+
if(BerkeleyDB_INCLUDE_DIR)
122+
file(
123+
STRINGS
124+
${BerkeleyDB_INCLUDE_DIR}/db.h
125+
results
126+
REGEX "^[ \t]*#[ \t]*define[ \t]+DB_VERSION_(MAJOR|MINOR|PATCH)[ \t]+[0-9]+[^\r\n]*$"
127+
)
128+
129+
unset(BerkeleyDB_VERSION)
130+
131+
foreach(item MAJOR MINOR PATCH)
132+
foreach(line ${results})
133+
if(line MATCHES "^[ \t]*#[ \t]*define[ \t]+DB_VERSION_${item}[ \t]+([0-9]+)[^\r\n]*$")
134+
if(DEFINED BerkeleyDB_VERSION)
135+
string(APPEND BerkeleyDB_VERSION ".${CMAKE_MATCH_1}")
136+
else()
137+
set(BerkeleyDB_VERSION "${CMAKE_MATCH_1}")
138+
endif()
139+
endif()
140+
endforeach()
141+
endforeach()
142+
endif()
143+
endblock()
144+
112145
mark_as_advanced(
113146
BerkeleyDB_DB1_INCLUDE_DIR
114147
BerkeleyDB_INCLUDE_DIR
@@ -121,6 +154,7 @@ find_package_handle_standard_args(
121154
BerkeleyDB_LIBRARY
122155
BerkeleyDB_INCLUDE_DIR
123156
_berkeleydb_sanity_check
157+
VERSION_VAR BerkeleyDB_VERSION
124158
REASON_FAILURE_MESSAGE "${_reason}"
125159
)
126160

cmake/cmake/modules/FindCdb.cmake

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,7 @@ endif()
5252

5353
find_library(
5454
Cdb_LIBRARY
55-
NAMES
56-
cdb
57-
# TODO: Which system still has cdb built in the default C library? In such
58-
# case this find module should be refactored to search the built-in library
59-
# similar to how FindIconv does it. Otherwise, more likely, this should be
60-
# removed from here.
61-
c
55+
NAMES cdb
6256
PATHS ${PC_Cdb_LIBRARY_DIRS}
6357
DOC "The path to the cdb library"
6458
)

cmake/cmake/modules/FindTokyoCabinet.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ include(FindPackageHandleStandardArgs)
2929
set_package_properties(
3030
TokyoCabinet
3131
PROPERTIES
32-
URL "https://en.wikipedia.org/wiki/Tkrzw"
32+
URL "https://dbmx.net/tokyocabinet/"
3333
DESCRIPTION "Key-value database library"
3434
)
3535

cmake/cmake/presets/all-enabled.json

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,8 @@
1515
"EXT_CALENDAR": true,
1616
"EXT_CURL": true,
1717
"EXT_DBA": true,
18-
"EXT_DBA_DBM": true,
19-
"EXT_DBA_GDBM": true,
2018
"EXT_DBA_LMDB": true,
21-
"EXT_DBA_NDBM": true,
19+
"EXT_DBA_QDBM": true,
2220
"EXT_DBA_TCADB": true,
2321
"EXT_DL_TEST": true,
2422
"EXT_ENCHANT": true,
@@ -112,9 +110,6 @@
112110
"PHP_DTRACE": true,
113111

114112
"EXT_DBA_CDB_EXTERNAL": true,
115-
"EXT_DBA_DBM": false,
116-
"EXT_DBA_GDBM": false,
117-
"EXT_DBA_QDBM": true,
118113
"EXT_OPENSSL_KERBEROS": true,
119114
"EXT_OPENSSL_SYSTEM_CIPHERS": true,
120115
"EXT_PCRE_EXTERNAL": true,

0 commit comments

Comments
 (0)