diff options
author | eban <eban@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2002-12-13 14:55:30 +0000 |
---|---|---|
committer | eban <eban@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2002-12-13 14:55:30 +0000 |
commit | f360ad8106ea9a485d47543622edeb1288ac70ef (patch) | |
tree | 7372a17ffe00e892d05f008e8013265e10256bb8 /ext | |
parent | e71c9d1c4a6806a33fa89f49e0090f0f63e71a2c (diff) |
* ext/dbm/extconf.rb: backported from 1.7.
* ext/dbm/dbm.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_6@3142 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r-- | ext/dbm/dbm.c | 2 | ||||
-rw-r--r-- | ext/dbm/extconf.rb | 54 |
2 files changed, 50 insertions, 6 deletions
diff --git a/ext/dbm/dbm.c b/ext/dbm/dbm.c index 94b07712c3..8edce9b9d0 100644 --- a/ext/dbm/dbm.c +++ b/ext/dbm/dbm.c @@ -18,7 +18,7 @@ #ifdef HAVE_SYS_CDEFS_H # include <sys/cdefs.h> #endif -#include <ndbm.h> +#include DBM_HDR #include <fcntl.h> #include <errno.h> diff --git a/ext/dbm/extconf.rb b/ext/dbm/extconf.rb index 9ce235a2b5..5c1afe7d34 100644 --- a/ext/dbm/extconf.rb +++ b/ext/dbm/extconf.rb @@ -1,13 +1,57 @@ require 'mkmf' dir_config("dbm") -if have_library("gdbm", "dbm_open") - gdbm = true + +dblib = with_config("dbm-type", nil) + +$dbm_conf_headers = { + "db" => ["db.h"], + "db1" => ["db1/ndbm.h", "db1.h", "ndbm.h"], + "db2" => ["db2/db.h", "db2.h", "db.h"], + "dbm" => ["ndbm.h"], + "gdbm" => ["gdbm-ndbm.h", "ndbm.h"], + "gdbm_compat" => ["gdbm-ndbm.h", "ndbm.h"], +} + +def db_check(db) + $dbm_conf_db_prefix = "" + $dbm_conf_have_gdbm = false + hsearch = "" + + case db + when /^db2?$/ + $dbm_conf_db_prefix = "__db_n" + hsearch = "-DDB_DBM_HSEARCH " + when "gdbm" + $dbm_conf_have_gdbm = true + end + + if have_library(db, db_prefix("dbm_open")) || have_func(db_prefix("dbm_open")) + for hdr in $dbm_conf_headers.fetch(db, ["ndbm.h"]) + if have_header(hdr.dup) + $CFLAGS += " " + hsearch + "-DDBM_HDR='<"+hdr+">'" + return true + end + end + end + return false end -gdbm or have_library("db", "dbm_open") or have_library("dbm", "dbm_open") + +def db_prefix(func) + $dbm_conf_db_prefix+func +end + +if dblib + db_check(dblib) +else + for dblib in %w(db db2 db1 dbm gdbm) + db_check(dblib) and break + end +end + have_header("cdefs.h") have_header("sys/cdefs.h") -if have_header("ndbm.h") and have_func("dbm_open") - have_func("dbm_clearerr") unless gdbm +if /DBM_HDR/ =~ $CFLAGS and have_func(db_prefix("dbm_open")) + have_func(db_prefix("dbm_clearerr")) unless $dbm_conf_have_gdbm create_makefile("dbm") end |