summaryrefslogtreecommitdiff
path: root/ext/dbm/extconf.rb
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-12-06 03:38:07 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-12-06 03:38:07 +0000
commit2f49f5ee0b257a2cb52b66ba36ab65bb2fa4641a (patch)
tree7d4801d1b1f935473696f364048b9b7e544b4a3c /ext/dbm/extconf.rb
parent79bc357902ff3ba94805a08557f741a6c389d759 (diff)
* ext/dbm/extconf.rb: detect gdbm_version in libgdbm.
* ext/dbm/dbm.c: make DBM::VERSION more informative for gdbm, qdbm and Berkeley DB 1.x. [ruby-dev:44944] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33959 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/dbm/extconf.rb')
-rw-r--r--ext/dbm/extconf.rb33
1 files changed, 33 insertions, 0 deletions
diff --git a/ext/dbm/extconf.rb b/ext/dbm/extconf.rb
index ba5cfe4243..6a4b8c069d 100644
--- a/ext/dbm/extconf.rb
+++ b/ext/dbm/extconf.rb
@@ -40,6 +40,32 @@ def headers.db_check(db, hdr)
result
end
+def have_libvar(var, headers = nil, opt = "", &b)
+ checking_for checking_message([*var].compact.join(' '), headers, opt) do
+ try_libvar(var, headers, opt, &b)
+ end
+end
+
+def try_libvar(var, headers = nil, opt = "", &b)
+ var, type = *var
+ if try_link(<<"SRC", opt, &b)
+#{cpp_include(headers)}
+/*top*/
+int main(int argc, char *argv[]) {
+ typedef #{type || 'int'} conftest_type;
+ extern conftest_type #{var};
+ conftest_type *conftest_var = &#{var};
+ return 0;
+}
+SRC
+ $defs.push(format("-DHAVE_LIBVAR_%s", var.tr_cpp))
+ true
+ else
+ false
+ end
+end
+
+
def headers.db_check2(db, hdr)
hsearch = nil
@@ -54,6 +80,13 @@ def headers.db_check2(db, hdr)
(db == 'libc' ? have_func('dbm_open("", 0, 0)', hdr, hsearch) :
have_library(db, 'dbm_open("", 0, 0)', hdr, hsearch)) and
have_func('dbm_clearerr((DBM *)0)', hdr, hsearch)
+ if /gdbm/ =~ db
+ have_var("gdbm_version", hdr, hsearch)
+ # gdbm_version is not declared by ndbm.h until gdbm 1.8.3.
+ # We can't include ndbm.h and gdbm.h because they both define datum type.
+ # ndbm.h includes gdbm.h and gdbm_version is declared since gdbm 1.9.
+ have_libvar(["gdbm_version", "char *"], hdr, hsearch)
+ end
if hsearch
$defs << hsearch
@defs = hsearch